;hexdump of $100000: ;$100000 = $12 ;$100001 = $34 ;$100002 = $56 -;$100003 = $78
+;hexdump of $100000 ;$100000 = $78 ;$100001 = $56 ;$100002 = $34 -;$100003 = $12
MOVE.B #3,D0 represents the number 3.
@@ -45,72 +50,88 @@ How you go about defining numbers or text in your code varies wildly between ass
* The operand before the comma is the "source", and the operand after is the "destination." For example, MOVE.L D3,D2 takes the value in D3 and stores it into D2, not the other way around. This is the opposite of x86 and ARM, which have the source on the right and the destination on the left.
-
-Data blocks, on the other hand, begin with DC.B, DC.W, or DC.L and each represents a constant numeric value. Strangely, you do NOT prefix these with # to signify them as constants (doing so will cause an error on most assemblers). However, you can use the $ or % modifiers to denote hexadecimal or binary.
+Data blocks, on the other hand, begin with DC.B, DC.W, or DC.L and each represents a constant numeric value. You do NOT prefix these with # to signify them as constants (doing so will cause an error on most assemblers). However, you can use the $ or % modifiers to denote hexadecimal or binary.
Keep in mind that there is no requirement to use hexadecimal, decimal, or binary in your source code. It all gets converted to binary anyway. However, it is recommended to use the notation that is appropriate for how your data is meant to be interpreted, for readability purposes.
===Data Registers===
There are eight 32-bit data registers on the 68000, numbered D0-D7. As the name implies, these are designed to hold data. Much like in [[ARM Assembly]], each one is identical in terms of which commands it can use. A command that can be used for D0 can be used for any other D-register.
-.B, 2 for .W, 4 for .L).
-MOVE.B it doesn't matter.
====Effective Address====
A calculated offset can be saved to an address register with the LEA command, which stands for "Load Effective Address." [[x86 Assembly]] also has this command, and it serves the same purpose. The syntax for it can be a bit misleading depending on your assembler.
-LEA cannot dereference an address.
If you don't want to store the effective address in an address register, you can use PEA (push effective address) to put it onto the stack instead.
-SP but it is also address register A7. This register is handled differently than the other address registers when pushing bytes onto the stack. A byte value pushed onto the stack will be padded to the right. The stack needs to pad byte-length data so that it can stay word-aligned at all times. Otherwise the CPU would crash as soon as you tried to use the stack for anything other than a byte!
@@ -124,48 +145,48 @@ The 68000 can work with 8-bit, 16-bit, or 32-bit values. Some commands only work
If you don't specify a length with your command, it usually defaults to word length, but ultimately it depends on the command you are using. (Some commands cannot be used at word length.)
Bytes and words moved into a register are always stored on the right-hand side. For example:
-CCR. The 68000 has no built-in commands like CLC for clearing/setting individual flags. Rather, you can alter them directly with MOVE,AND,OR, and EOR. Unfortunately, this means you'll have to remember which bits represent which flags. Or, if your assembler supports macros, you can define a macro that handles this for you.
The flags update automatically after most operations, and take into consideration the operand sizes when doing so. Check out this example:
-ADD.B, D0 now contains $1200, and the extend, carry, and zero flags are all set. Had we done ADD.W, we would get $1300 in D0 with none of those flags set. The flags are based on what the actual instruction "sees", not the entire register at all times.
* X: The eXtend flag is bit 4 of the CCR, and is similar to the carry flag. It gets set and cleared often for the same reasons and is used with the ADDX, SUBX, NEGX, ROXL, and ROXR commands. Why the 68000 has both this and the carry flag, I still don't know.
-
* N: The negative flag is bit 3 of the CCR, and is set when the last operation resulted in a "negative" value. What constitutes a negative value depends on the size of the last operation - for .B instructions, $80-$FF. For .W instructions, $8000-$FFFF, and for .L instructions, $80000000-$FFFFFFFF.
-
* Z: The zero flag is bit 2 of the CCR and works like you would expect - it's set whenever an operation results in zero. Unlike x86 Assembly, this also includes moving 0 directly into a register, clearing a register or memory with CLR, etc.
-
* V: The overflow flag is bit 1 of the CCR. It is set whenever a math operation results in a value crossing the $7F-$80 boundary. (Wraparound from 00 to FF doesn't count as overflow, but it does set the carry flag.)
-
* C: The carry flag is bit 0 of the CCR. It is set when a math operation results in a carry or borrow. Rolling over from FF to 00, or a 1 getting "pushed out" via a bit shift or rotate, set the carry flag. When using CMP, the carry flag determines the unsigned magnitude comparison. Carry set is less than, carry clear is greater than or equal.
-
-
In truth, the flags are a 16-bit register, of which the CCR is just the "low half". The SR (status register) is the full 16-bit register.
There are a few additional flags in the upper half, which are used by the operating system. You can read these but for the most part you won't need to write to them.
@@ -189,13 +210,15 @@ The 68000 supports 7 different interrupts, often called IRQs or Interrupt Reques
==Alignment==
The 68000 can only read or write words and longs at even addresses. Doing so at an odd address will result in the CPU crashing. (Note that reading byte data will not cause a crash regardless of whether it's located at an odd or even address.) This isn't usually a problem, but it can be if the programmer is not careful with the way their data is organized. Consider the following example:
-EVEN directive can be placed after a series of bytes. If the byte count is odd, EVEN will pad the data with an extra byte. If it's already even, the EVEN command is ignored. This saves you the trouble of having to count a long series of bytes without worrying about wasting space.
-ADDA.L #1,A0 and ADDA.L #1,A1 would have worked also, instead of the dummy read. The 68000 gives the programmer a lot of different ways to do a task.
diff --git a/Lang/68000-Assembly/Musical-scale b/Lang/68000-Assembly/Musical-scale
new file mode 120000
index 0000000000..0a23b13b4e
--- /dev/null
+++ b/Lang/68000-Assembly/Musical-scale
@@ -0,0 +1 @@
+../../Task/Musical-scale/68000-Assembly
\ No newline at end of file
diff --git a/Lang/8080-Assembly/Align-columns b/Lang/8080-Assembly/Align-columns
new file mode 120000
index 0000000000..d9134cb487
--- /dev/null
+++ b/Lang/8080-Assembly/Align-columns
@@ -0,0 +1 @@
+../../Task/Align-columns/8080-Assembly
\ No newline at end of file
diff --git a/Lang/ABAP/00-LANG.txt b/Lang/ABAP/00-LANG.txt
index 446b44c265..819bd4cbc5 100644
--- a/Lang/ABAP/00-LANG.txt
+++ b/Lang/ABAP/00-LANG.txt
@@ -1,2 +1,14 @@
-{{stub}}{{language|site=http://www.sdn.sap.com/irj/sdn/abap}}
-ABAP (Advanced Business Application Programming) is a programming language developed by the german software vendor SAP. It is mainly used to build high performance business applications.
\ No newline at end of file
+{{stub}}{{language
+|site=http://www.sdn.sap.com/irj/sdn/abap
+|safety=safe
+|strength=strong
+|compat=nominative
+|checking=static
+|tags=abap}}
+ABAP (Advanced Business Application Programming) is a programming language developed by the german software vendor SAP. It is mainly used to build high performance business applications.
+
+==Citation==
+*[https://en.wikipedia.org/wiki/ABAP]
+
+[[Category:Programming paradigm/Object-oriented]]
+[[Category:Programming paradigm/Imperative]]
\ No newline at end of file
diff --git a/Lang/ABC/Arithmetic-derivative b/Lang/ABC/Arithmetic-derivative
new file mode 120000
index 0000000000..4225078056
--- /dev/null
+++ b/Lang/ABC/Arithmetic-derivative
@@ -0,0 +1 @@
+../../Task/Arithmetic-derivative/ABC
\ No newline at end of file
diff --git a/Lang/ALGOL-60/Even-or-odd b/Lang/ALGOL-60/Even-or-odd
new file mode 120000
index 0000000000..13baeccf6c
--- /dev/null
+++ b/Lang/ALGOL-60/Even-or-odd
@@ -0,0 +1 @@
+../../Task/Even-or-odd/ALGOL-60
\ No newline at end of file
diff --git a/Lang/ALGOL-60/Harmonic-series b/Lang/ALGOL-60/Harmonic-series
new file mode 120000
index 0000000000..a1eefb4086
--- /dev/null
+++ b/Lang/ALGOL-60/Harmonic-series
@@ -0,0 +1 @@
+../../Task/Harmonic-series/ALGOL-60
\ No newline at end of file
diff --git a/Lang/ALGOL-60/Nth-root b/Lang/ALGOL-60/Nth-root
new file mode 120000
index 0000000000..3032f52453
--- /dev/null
+++ b/Lang/ALGOL-60/Nth-root
@@ -0,0 +1 @@
+../../Task/Nth-root/ALGOL-60
\ No newline at end of file
diff --git a/Lang/ALGOL-60/Square-free-integers b/Lang/ALGOL-60/Square-free-integers
new file mode 120000
index 0000000000..caff91a536
--- /dev/null
+++ b/Lang/ALGOL-60/Square-free-integers
@@ -0,0 +1 @@
+../../Task/Square-free-integers/ALGOL-60
\ No newline at end of file
diff --git a/Lang/ALGOL-60/Sum-of-a-series b/Lang/ALGOL-60/Sum-of-a-series
new file mode 120000
index 0000000000..48b6d3380c
--- /dev/null
+++ b/Lang/ALGOL-60/Sum-of-a-series
@@ -0,0 +1 @@
+../../Task/Sum-of-a-series/ALGOL-60
\ No newline at end of file
diff --git a/Lang/ALGOL-68/100-prisoners b/Lang/ALGOL-68/100-prisoners
new file mode 120000
index 0000000000..f6c4da597a
--- /dev/null
+++ b/Lang/ALGOL-68/100-prisoners
@@ -0,0 +1 @@
+../../Task/100-prisoners/ALGOL-68
\ No newline at end of file
diff --git a/Lang/ALGOL-68/Bitmap-B-zier-curves-Quadratic b/Lang/ALGOL-68/Bitmap-B-zier-curves-Quadratic
new file mode 120000
index 0000000000..30ab56c310
--- /dev/null
+++ b/Lang/ALGOL-68/Bitmap-B-zier-curves-Quadratic
@@ -0,0 +1 @@
+../../Task/Bitmap-B-zier-curves-Quadratic/ALGOL-68
\ No newline at end of file
diff --git a/Lang/ALGOL-68/Burrows-Wheeler-transform b/Lang/ALGOL-68/Burrows-Wheeler-transform
new file mode 120000
index 0000000000..203e0e501f
--- /dev/null
+++ b/Lang/ALGOL-68/Burrows-Wheeler-transform
@@ -0,0 +1 @@
+../../Task/Burrows-Wheeler-transform/ALGOL-68
\ No newline at end of file
diff --git a/Lang/ALGOL-68/Chernicks-Carmichael-numbers b/Lang/ALGOL-68/Chernicks-Carmichael-numbers
new file mode 120000
index 0000000000..ebdbb0354b
--- /dev/null
+++ b/Lang/ALGOL-68/Chernicks-Carmichael-numbers
@@ -0,0 +1 @@
+../../Task/Chernicks-Carmichael-numbers/ALGOL-68
\ No newline at end of file
diff --git a/Lang/ALGOL-68/Determinant-and-permanent b/Lang/ALGOL-68/Determinant-and-permanent
new file mode 120000
index 0000000000..e8a753594d
--- /dev/null
+++ b/Lang/ALGOL-68/Determinant-and-permanent
@@ -0,0 +1 @@
+../../Task/Determinant-and-permanent/ALGOL-68
\ No newline at end of file
diff --git a/Lang/ALGOL-68/Display-an-outline-as-a-nested-table b/Lang/ALGOL-68/Display-an-outline-as-a-nested-table
new file mode 120000
index 0000000000..41ea472cc8
--- /dev/null
+++ b/Lang/ALGOL-68/Display-an-outline-as-a-nested-table
@@ -0,0 +1 @@
+../../Task/Display-an-outline-as-a-nested-table/ALGOL-68
\ No newline at end of file
diff --git a/Lang/ALGOL-68/Elementary-cellular-automaton-Random-number-generator b/Lang/ALGOL-68/Elementary-cellular-automaton-Random-number-generator
new file mode 120000
index 0000000000..a4aed0fa0e
--- /dev/null
+++ b/Lang/ALGOL-68/Elementary-cellular-automaton-Random-number-generator
@@ -0,0 +1 @@
+../../Task/Elementary-cellular-automaton-Random-number-generator/ALGOL-68
\ No newline at end of file
diff --git a/Lang/ALGOL-68/Four-is-magic b/Lang/ALGOL-68/Four-is-magic
new file mode 120000
index 0000000000..007db868ed
--- /dev/null
+++ b/Lang/ALGOL-68/Four-is-magic
@@ -0,0 +1 @@
+../../Task/Four-is-magic/ALGOL-68
\ No newline at end of file
diff --git a/Lang/ALGOL-68/IBAN b/Lang/ALGOL-68/IBAN
new file mode 120000
index 0000000000..08ea01a928
--- /dev/null
+++ b/Lang/ALGOL-68/IBAN
@@ -0,0 +1 @@
+../../Task/IBAN/ALGOL-68
\ No newline at end of file
diff --git a/Lang/ALGOL-68/Jaro-similarity b/Lang/ALGOL-68/Jaro-similarity
new file mode 120000
index 0000000000..0255b5f0fa
--- /dev/null
+++ b/Lang/ALGOL-68/Jaro-similarity
@@ -0,0 +1 @@
+../../Task/Jaro-similarity/ALGOL-68
\ No newline at end of file
diff --git a/Lang/ALGOL-68/Longest-increasing-subsequence b/Lang/ALGOL-68/Longest-increasing-subsequence
new file mode 120000
index 0000000000..a09c83eed3
--- /dev/null
+++ b/Lang/ALGOL-68/Longest-increasing-subsequence
@@ -0,0 +1 @@
+../../Task/Longest-increasing-subsequence/ALGOL-68
\ No newline at end of file
diff --git a/Lang/ALGOL-68/Partition-function-P b/Lang/ALGOL-68/Partition-function-P
new file mode 120000
index 0000000000..98f6538801
--- /dev/null
+++ b/Lang/ALGOL-68/Partition-function-P
@@ -0,0 +1 @@
+../../Task/Partition-function-P/ALGOL-68
\ No newline at end of file
diff --git a/Lang/ALGOL-68/Pentagram b/Lang/ALGOL-68/Pentagram
new file mode 120000
index 0000000000..7ab101a89e
--- /dev/null
+++ b/Lang/ALGOL-68/Pentagram
@@ -0,0 +1 @@
+../../Task/Pentagram/ALGOL-68
\ No newline at end of file
diff --git a/Lang/ALGOL-W/Calculating-the-value-of-e b/Lang/ALGOL-W/Calculating-the-value-of-e
new file mode 120000
index 0000000000..0bccb15458
--- /dev/null
+++ b/Lang/ALGOL-W/Calculating-the-value-of-e
@@ -0,0 +1 @@
+../../Task/Calculating-the-value-of-e/ALGOL-W
\ No newline at end of file
diff --git a/Lang/ALGOL-W/McNuggets-problem b/Lang/ALGOL-W/McNuggets-problem
new file mode 120000
index 0000000000..74213b63b7
--- /dev/null
+++ b/Lang/ALGOL-W/McNuggets-problem
@@ -0,0 +1 @@
+../../Task/McNuggets-problem/ALGOL-W
\ No newline at end of file
diff --git a/Lang/ALGOL-W/Square-free-integers b/Lang/ALGOL-W/Square-free-integers
new file mode 120000
index 0000000000..c98b8e474a
--- /dev/null
+++ b/Lang/ALGOL-W/Square-free-integers
@@ -0,0 +1 @@
+../../Task/Square-free-integers/ALGOL-W
\ No newline at end of file
diff --git a/Lang/ANSI-BASIC/Angle-difference-between-two-bearings b/Lang/ANSI-BASIC/Angle-difference-between-two-bearings
new file mode 120000
index 0000000000..de48f860b4
--- /dev/null
+++ b/Lang/ANSI-BASIC/Angle-difference-between-two-bearings
@@ -0,0 +1 @@
+../../Task/Angle-difference-between-two-bearings/ANSI-BASIC
\ No newline at end of file
diff --git a/Lang/ANSI-BASIC/Leonardo-numbers b/Lang/ANSI-BASIC/Leonardo-numbers
new file mode 120000
index 0000000000..eeb51e71aa
--- /dev/null
+++ b/Lang/ANSI-BASIC/Leonardo-numbers
@@ -0,0 +1 @@
+../../Task/Leonardo-numbers/ANSI-BASIC
\ No newline at end of file
diff --git a/Lang/ANSI-BASIC/Luhn-test-of-credit-card-numbers b/Lang/ANSI-BASIC/Luhn-test-of-credit-card-numbers
new file mode 120000
index 0000000000..5e8c5fe6dd
--- /dev/null
+++ b/Lang/ANSI-BASIC/Luhn-test-of-credit-card-numbers
@@ -0,0 +1 @@
+../../Task/Luhn-test-of-credit-card-numbers/ANSI-BASIC
\ No newline at end of file
diff --git a/Lang/ANSI-BASIC/Nth-root b/Lang/ANSI-BASIC/Nth-root
new file mode 120000
index 0000000000..089f4d872e
--- /dev/null
+++ b/Lang/ANSI-BASIC/Nth-root
@@ -0,0 +1 @@
+../../Task/Nth-root/ANSI-BASIC
\ No newline at end of file
diff --git a/Lang/ANSI-BASIC/Temperature-conversion b/Lang/ANSI-BASIC/Temperature-conversion
new file mode 120000
index 0000000000..af167d778a
--- /dev/null
+++ b/Lang/ANSI-BASIC/Temperature-conversion
@@ -0,0 +1 @@
+../../Task/Temperature-conversion/ANSI-BASIC
\ No newline at end of file
diff --git a/Lang/APL/Arithmetic-derivative b/Lang/APL/Arithmetic-derivative
new file mode 120000
index 0000000000..c5dd2fd89b
--- /dev/null
+++ b/Lang/APL/Arithmetic-derivative
@@ -0,0 +1 @@
+../../Task/Arithmetic-derivative/APL
\ No newline at end of file
diff --git a/Lang/ARM-Assembly/Pancake-numbers b/Lang/ARM-Assembly/Pancake-numbers
new file mode 120000
index 0000000000..7bcfc9ff51
--- /dev/null
+++ b/Lang/ARM-Assembly/Pancake-numbers
@@ -0,0 +1 @@
+../../Task/Pancake-numbers/ARM-Assembly
\ No newline at end of file
diff --git a/Lang/ASIC/Dragon-curve b/Lang/ASIC/Dragon-curve
new file mode 120000
index 0000000000..7538c55bbc
--- /dev/null
+++ b/Lang/ASIC/Dragon-curve
@@ -0,0 +1 @@
+../../Task/Dragon-curve/ASIC
\ No newline at end of file
diff --git a/Lang/ASIC/Luhn-test-of-credit-card-numbers b/Lang/ASIC/Luhn-test-of-credit-card-numbers
new file mode 120000
index 0000000000..30c2c72edb
--- /dev/null
+++ b/Lang/ASIC/Luhn-test-of-credit-card-numbers
@@ -0,0 +1 @@
+../../Task/Luhn-test-of-credit-card-numbers/ASIC
\ No newline at end of file
diff --git a/Lang/ASIC/Temperature-conversion b/Lang/ASIC/Temperature-conversion
new file mode 120000
index 0000000000..312278bfcd
--- /dev/null
+++ b/Lang/ASIC/Temperature-conversion
@@ -0,0 +1 @@
+../../Task/Temperature-conversion/ASIC
\ No newline at end of file
diff --git a/Lang/Action-/Arithmetic-derivative b/Lang/Action-/Arithmetic-derivative
new file mode 120000
index 0000000000..8206b6a192
--- /dev/null
+++ b/Lang/Action-/Arithmetic-derivative
@@ -0,0 +1 @@
+../../Task/Arithmetic-derivative/Action-
\ No newline at end of file
diff --git a/Lang/ActionScript/00-LANG.txt b/Lang/ActionScript/00-LANG.txt
index 14a7dc41bf..4fe99ed760 100644
--- a/Lang/ActionScript/00-LANG.txt
+++ b/Lang/ActionScript/00-LANG.txt
@@ -4,7 +4,8 @@
|strength=strong
|safety=safe
|checking=static
-|LCT=yes}}
+|LCT=yes
+|tags=actionscript, as}}
{{Language programming paradigm|Distributed}}
{{Language programming paradigm|Imperative}}
diff --git a/Lang/Ada/00-LANG.txt b/Lang/Ada/00-LANG.txt
index f17f9738ab..e9eb8d687d 100644
--- a/Lang/Ada/00-LANG.txt
+++ b/Lang/Ada/00-LANG.txt
@@ -8,7 +8,7 @@
|strength=strong
|safety=safe
|LCT=yes
-|bnf=http://www.adaic.org/standards/1zrm/html/RM-P.html}}'''Ada''' is a structured, statically typed [[imperative programming|imperative]] computer programming language. Ada was initially standardized by [[ANSI]] in 1983 and by [[ISO]] in 1987. This version of the language is commonly known as [[Ada 83]]. The next version was standardized by ISO in 1995 (ISO/IEC 8652:1995) and is commonly known as [[Ada 95]]. Following that ISO published ISO/IEC 8652:1995/Amd 1:2007 in 2007, which is commonly known as [[Ada 2005]]. Most recently ISO published [http://www.ada-auth.org/standards/12rm/html/RM-TTL.html ISO/IEC 8652:2012(E)], commonly known as [[Ada 2012]]. Formally only the most recent version of the language is known as '''Ada'''.
+|bnf=http://www.ada-auth.org/standards/22rm/html/RM-P-1.html}}'''Ada''' is a structured, statically typed [[imperative programming|imperative]] computer programming language. Ada was initially standardized by [[ANSI]] in 1983 and by [[ISO]] in 1987. This version of the language is commonly known as [[Ada 83]]. The next version was standardized by ISO in 1995 (ISO/IEC 8652:1995) and is commonly known as [[Ada 95]]. Following that ISO published ISO/IEC 8652:1995/Amd 1:2007 in 2007, which is commonly known as [[Ada 2005]]. Afterwards they published ISO/IEC 8652:2012(E), also known as [[Ada 2012]]. Most recently ISO published [http://www.ada-auth.org/standards/22rm/html/RM-TTL.html ISO/IEC 8652:2023], commonly known as [[Ada 2022]]. Formally only the most recent version of the language is known as '''Ada'''.
The language is named after [[wp:Ada_Lovelace|Augusta Ada King, Countess of Lovelace]] thought to be the first ever programmer. Initially it was designed for [http://www.defense.gov U.S. Department of Defense]. The language is used for large and mission-critical systems. See [[wp:Ada_(programming_language)|also]].
==Grammar==
diff --git a/Lang/Ada/Arithmetic-derivative b/Lang/Ada/Arithmetic-derivative
new file mode 120000
index 0000000000..87dd4d6940
--- /dev/null
+++ b/Lang/Ada/Arithmetic-derivative
@@ -0,0 +1 @@
+../../Task/Arithmetic-derivative/Ada
\ No newline at end of file
diff --git a/Lang/Ada/Blum-integer b/Lang/Ada/Blum-integer
new file mode 120000
index 0000000000..48b2715109
--- /dev/null
+++ b/Lang/Ada/Blum-integer
@@ -0,0 +1 @@
+../../Task/Blum-integer/Ada
\ No newline at end of file
diff --git a/Lang/Ada/Chaos-game b/Lang/Ada/Chaos-game
new file mode 120000
index 0000000000..456fd72f97
--- /dev/null
+++ b/Lang/Ada/Chaos-game
@@ -0,0 +1 @@
+../../Task/Chaos-game/Ada
\ No newline at end of file
diff --git a/Lang/Ada/Lah-numbers b/Lang/Ada/Lah-numbers
new file mode 120000
index 0000000000..e4f08d947d
--- /dev/null
+++ b/Lang/Ada/Lah-numbers
@@ -0,0 +1 @@
+../../Task/Lah-numbers/Ada
\ No newline at end of file
diff --git a/Lang/Ada/Left-factorials b/Lang/Ada/Left-factorials
new file mode 120000
index 0000000000..8c62b38a57
--- /dev/null
+++ b/Lang/Ada/Left-factorials
@@ -0,0 +1 @@
+../../Task/Left-factorials/Ada
\ No newline at end of file
diff --git a/Lang/Ada/Sierpinski-pentagon b/Lang/Ada/Sierpinski-pentagon
new file mode 120000
index 0000000000..d3c2f495a7
--- /dev/null
+++ b/Lang/Ada/Sierpinski-pentagon
@@ -0,0 +1 @@
+../../Task/Sierpinski-pentagon/Ada
\ No newline at end of file
diff --git a/Lang/Ada/Smallest-number-k-such-that-k+2^m-is-composite-for-all-m-less-than-k b/Lang/Ada/Smallest-number-k-such-that-k+2^m-is-composite-for-all-m-less-than-k
new file mode 120000
index 0000000000..acb5a83713
--- /dev/null
+++ b/Lang/Ada/Smallest-number-k-such-that-k+2^m-is-composite-for-all-m-less-than-k
@@ -0,0 +1 @@
+../../Task/Smallest-number-k-such-that-k+2^m-is-composite-for-all-m-less-than-k/Ada
\ No newline at end of file
diff --git a/Lang/AmigaBASIC/Chaos-game b/Lang/AmigaBASIC/Chaos-game
new file mode 120000
index 0000000000..06fb31b581
--- /dev/null
+++ b/Lang/AmigaBASIC/Chaos-game
@@ -0,0 +1 @@
+../../Task/Chaos-game/AmigaBASIC
\ No newline at end of file
diff --git a/Lang/Applesoft-BASIC/00-LANG.txt b/Lang/Applesoft-BASIC/00-LANG.txt
index b47ab777d1..854387033b 100644
--- a/Lang/Applesoft-BASIC/00-LANG.txt
+++ b/Lang/Applesoft-BASIC/00-LANG.txt
@@ -7,4 +7,5 @@
* [[wp:Applesoft BASIC|Wikipedia: Applesoft BASIC]]
* [http://www.landsnail.com/a2ref.htm Apple II Programmer's Reference] from ][ In a Mac, via [http://www.landsnail.com/ Landsnail.com]
* [http://www.hoist-point.com/applesoft_basic_tutorial.htm AppleSoft BASIC tutorial for absolute beginners]
+* [https://www.calormen.com/jsbasic/ Applesoft BASIC in Javascript] On-line interpreter
* ''[[Tasks not implemented in Applesoft BASIC|Tasks not implemented in Applesoft BASIC]]''
\ No newline at end of file
diff --git a/Lang/Applesoft-BASIC/Dragon-curve b/Lang/Applesoft-BASIC/Dragon-curve
new file mode 120000
index 0000000000..89a81bf5e7
--- /dev/null
+++ b/Lang/Applesoft-BASIC/Dragon-curve
@@ -0,0 +1 @@
+../../Task/Dragon-curve/Applesoft-BASIC
\ No newline at end of file
diff --git a/Lang/Aquarius-BASIC/00-LANG.txt b/Lang/Aquarius-BASIC/00-LANG.txt
index 787837afb3..1314ae0882 100644
--- a/Lang/Aquarius-BASIC/00-LANG.txt
+++ b/Lang/Aquarius-BASIC/00-LANG.txt
@@ -2,4 +2,37 @@
|exec=interpreted
|tags=basic,aquariusbasic
}}
-{{Implementation|BASIC}}'''Aquarius BASIC''' refers to the more or less stripped-down releases of Microsoft BASIC for the Mattel/Radofin Aquarius. The built-in ROM BASIC was seriously restricted since the system only included 4K of RAM and 8K of ROM by default. Minus the RAM used for video and system management, only about 1.7K or RAM were usable by default; the optionally available Extended Microsoft BASIC that came on ROM cartridge was somewhat more generous, and RAM expansion cartridges were available.
\ No newline at end of file
+{{Implementation|BASIC}}'''Aquarius BASIC''' refers to the more or less stripped-down releases of Microsoft BASIC for the Mattel/Radofin Aquarius, a home computer released in 1983.
+
+The built-in ROM BASIC was seriously restricted since the system only included 4K of RAM and 8K of ROM by default. Minus the RAM used for video and system management, only about 1.7K of RAM were usable by default; the optionally available Extended Microsoft BASIC that came on ROM cartridge was somewhat more generous, and RAM expansion cartridges were available.
+
+BASIC lines can be a maximum of 72 characters long. Only the first two characters of a variable name are significant, so e.g. ABC and ABBA will contain the same value:
+POKE 13312,7 will turn the border color to white. BASIC programs start at 0x3901.[https://www.vdsteenoven.com/aquarius/malloc.html]
+
+BASIC can set and unset 80x72-resolution pixels on the Aquarius with the PSET and PRESET commands (each text character consists of 2x3 pixels). This program for instance draws an ellipsis:
+CLEAR 200 will reserve 200 bytes for strings. You can check with PRINT FRE("a") how much unused string space is still available.
+
+Emulators of the Mattel Aquarius include MAME and [https://aquarius.je/aqualite/ AquaLite].
+
+==See Also==
+* [[wp:Mattel Aquarius|Mattel Aquarius]] at Wikipedia
+* [https://archive.org/search?query=mattel+aquarius Aquarius manuals at the Internet Archive]
\ No newline at end of file
diff --git a/Lang/Aquarius-BASIC/Archimedean-spiral b/Lang/Aquarius-BASIC/Archimedean-spiral
new file mode 120000
index 0000000000..a52a300e36
--- /dev/null
+++ b/Lang/Aquarius-BASIC/Archimedean-spiral
@@ -0,0 +1 @@
+../../Task/Archimedean-spiral/Aquarius-BASIC
\ No newline at end of file
diff --git a/Lang/Aquarius-BASIC/Colour-bars-Display b/Lang/Aquarius-BASIC/Colour-bars-Display
new file mode 120000
index 0000000000..5113e0e205
--- /dev/null
+++ b/Lang/Aquarius-BASIC/Colour-bars-Display
@@ -0,0 +1 @@
+../../Task/Colour-bars-Display/Aquarius-BASIC
\ No newline at end of file
diff --git a/Lang/Aquarius-BASIC/Mandelbrot-set b/Lang/Aquarius-BASIC/Mandelbrot-set
new file mode 120000
index 0000000000..e078ca10a9
--- /dev/null
+++ b/Lang/Aquarius-BASIC/Mandelbrot-set
@@ -0,0 +1 @@
+../../Task/Mandelbrot-set/Aquarius-BASIC
\ No newline at end of file
diff --git a/Lang/Aquarius-BASIC/Matrix-digital-rain b/Lang/Aquarius-BASIC/Matrix-digital-rain
new file mode 120000
index 0000000000..227ab761a1
--- /dev/null
+++ b/Lang/Aquarius-BASIC/Matrix-digital-rain
@@ -0,0 +1 @@
+../../Task/Matrix-digital-rain/Aquarius-BASIC
\ No newline at end of file
diff --git a/Lang/Aquarius-BASIC/Musical-scale b/Lang/Aquarius-BASIC/Musical-scale
new file mode 120000
index 0000000000..16fb0326f5
--- /dev/null
+++ b/Lang/Aquarius-BASIC/Musical-scale
@@ -0,0 +1 @@
+../../Task/Musical-scale/Aquarius-BASIC
\ No newline at end of file
diff --git a/Lang/Aquarius-BASIC/Terminal-control-Display-an-extended-character b/Lang/Aquarius-BASIC/Terminal-control-Display-an-extended-character
new file mode 120000
index 0000000000..908e3614b8
--- /dev/null
+++ b/Lang/Aquarius-BASIC/Terminal-control-Display-an-extended-character
@@ -0,0 +1 @@
+../../Task/Terminal-control-Display-an-extended-character/Aquarius-BASIC
\ No newline at end of file
diff --git a/Lang/Arturo/00-LANG.txt b/Lang/Arturo/00-LANG.txt
index e01d1ab72c..7424af10da 100644
--- a/Lang/Arturo/00-LANG.txt
+++ b/Lang/Arturo/00-LANG.txt
@@ -16,8 +16,8 @@ The language has been designed following some very simple and straightforward pr
atari800 -basic. Some important keys in Atari800 are F1=Settings, F5=Reset, F7=Break, F9=Quit, F10=Screenshot; see [https://github.com/atari800/atari800/blob/master/DOC/USAGE DOC/USAGE] for more. Lowercase characters in strings can be entered by first pressing Caps Lock in Atari800.
+
+In Atari800, folders on the host computer can be mounted in ''Emulator Configuration ⇨ Host Device Settings'', so then you can e.g. use LOAD "H1:MYPROG.BAS" to load a program from local disk. By default, folders are mounted read-only.
+
+BASIC programs in tokenized form are loaded and saved with LOAD and SAVE; in ASCII/ATASCII format you load them with ENTER and save them with LIST, e.g. LIST “H1:PROGRAM.LST”.
+
+After 9 minutes of inactivity, a screen saver (called attract mode by Atari) will activate and cycle colors. This can be stopped by an occasional POKE 77,0 to reset the timer.
+
+Like in Palo Alto Tiny BASIC, commands can be abbreviated by their first (unique) letters and a period, e.g. L. for LIST or GR. for GRAPHICS.
+
+==See Also==
+*[https://en.wikipedia.org/wiki/Atari_BASIC Atari BASIC] in Wikipedia
\ No newline at end of file
diff --git a/Lang/Atari-BASIC/Archimedean-spiral b/Lang/Atari-BASIC/Archimedean-spiral
new file mode 120000
index 0000000000..3e75563330
--- /dev/null
+++ b/Lang/Atari-BASIC/Archimedean-spiral
@@ -0,0 +1 @@
+../../Task/Archimedean-spiral/Atari-BASIC
\ No newline at end of file
diff --git a/Lang/Atari-BASIC/Chaos-game b/Lang/Atari-BASIC/Chaos-game
new file mode 120000
index 0000000000..f88e0f8ada
--- /dev/null
+++ b/Lang/Atari-BASIC/Chaos-game
@@ -0,0 +1 @@
+../../Task/Chaos-game/Atari-BASIC
\ No newline at end of file
diff --git a/Lang/Atari-BASIC/Color-of-a-screen-pixel b/Lang/Atari-BASIC/Color-of-a-screen-pixel
new file mode 120000
index 0000000000..b097621245
--- /dev/null
+++ b/Lang/Atari-BASIC/Color-of-a-screen-pixel
@@ -0,0 +1 @@
+../../Task/Color-of-a-screen-pixel/Atari-BASIC
\ No newline at end of file
diff --git a/Lang/Atari-BASIC/Colour-bars-Display b/Lang/Atari-BASIC/Colour-bars-Display
new file mode 120000
index 0000000000..03db8dce96
--- /dev/null
+++ b/Lang/Atari-BASIC/Colour-bars-Display
@@ -0,0 +1 @@
+../../Task/Colour-bars-Display/Atari-BASIC
\ No newline at end of file
diff --git a/Lang/Atari-BASIC/Draw-a-clock b/Lang/Atari-BASIC/Draw-a-clock
new file mode 120000
index 0000000000..f8dd467da4
--- /dev/null
+++ b/Lang/Atari-BASIC/Draw-a-clock
@@ -0,0 +1 @@
+../../Task/Draw-a-clock/Atari-BASIC
\ No newline at end of file
diff --git a/Lang/Atari-BASIC/Mandelbrot-set b/Lang/Atari-BASIC/Mandelbrot-set
new file mode 120000
index 0000000000..45e66ccff0
--- /dev/null
+++ b/Lang/Atari-BASIC/Mandelbrot-set
@@ -0,0 +1 @@
+../../Task/Mandelbrot-set/Atari-BASIC
\ No newline at end of file
diff --git a/Lang/Atari-BASIC/Musical-scale b/Lang/Atari-BASIC/Musical-scale
new file mode 120000
index 0000000000..b870e25059
--- /dev/null
+++ b/Lang/Atari-BASIC/Musical-scale
@@ -0,0 +1 @@
+../../Task/Musical-scale/Atari-BASIC
\ No newline at end of file
diff --git a/Lang/Atari-BASIC/Random-number-generator-device- b/Lang/Atari-BASIC/Random-number-generator-device-
new file mode 120000
index 0000000000..bc35b665ee
--- /dev/null
+++ b/Lang/Atari-BASIC/Random-number-generator-device-
@@ -0,0 +1 @@
+../../Task/Random-number-generator-device-/Atari-BASIC
\ No newline at end of file
diff --git a/Lang/Atari-BASIC/Reverse-a-string b/Lang/Atari-BASIC/Reverse-a-string
new file mode 120000
index 0000000000..c2ff7e214b
--- /dev/null
+++ b/Lang/Atari-BASIC/Reverse-a-string
@@ -0,0 +1 @@
+../../Task/Reverse-a-string/Atari-BASIC
\ No newline at end of file
diff --git a/Lang/Atari-BASIC/System-time b/Lang/Atari-BASIC/System-time
new file mode 120000
index 0000000000..c4df1e6a39
--- /dev/null
+++ b/Lang/Atari-BASIC/System-time
@@ -0,0 +1 @@
+../../Task/System-time/Atari-BASIC
\ No newline at end of file
diff --git a/Lang/Atari-BASIC/Terminal-control-Hiding-the-cursor b/Lang/Atari-BASIC/Terminal-control-Hiding-the-cursor
new file mode 120000
index 0000000000..78972a34b6
--- /dev/null
+++ b/Lang/Atari-BASIC/Terminal-control-Hiding-the-cursor
@@ -0,0 +1 @@
+../../Task/Terminal-control-Hiding-the-cursor/Atari-BASIC
\ No newline at end of file
diff --git a/Lang/Atari-BASIC/Terminal-control-Inverse-video b/Lang/Atari-BASIC/Terminal-control-Inverse-video
new file mode 120000
index 0000000000..8c57f75946
--- /dev/null
+++ b/Lang/Atari-BASIC/Terminal-control-Inverse-video
@@ -0,0 +1 @@
+../../Task/Terminal-control-Inverse-video/Atari-BASIC
\ No newline at end of file
diff --git a/Lang/Atari-BASIC/Terminal-control-Positional-read b/Lang/Atari-BASIC/Terminal-control-Positional-read
new file mode 120000
index 0000000000..a0575b2278
--- /dev/null
+++ b/Lang/Atari-BASIC/Terminal-control-Positional-read
@@ -0,0 +1 @@
+../../Task/Terminal-control-Positional-read/Atari-BASIC
\ No newline at end of file
diff --git a/Lang/Atari-BASIC/Terminal-control-Ringing-the-terminal-bell b/Lang/Atari-BASIC/Terminal-control-Ringing-the-terminal-bell
new file mode 120000
index 0000000000..3666cabb9e
--- /dev/null
+++ b/Lang/Atari-BASIC/Terminal-control-Ringing-the-terminal-bell
@@ -0,0 +1 @@
+../../Task/Terminal-control-Ringing-the-terminal-bell/Atari-BASIC
\ No newline at end of file
diff --git a/Lang/AutoHotKey-V2/00-LANG.txt b/Lang/AutoHotKey-V2/00-LANG.txt
deleted file mode 100644
index a333f928af..0000000000
--- a/Lang/AutoHotKey-V2/00-LANG.txt
+++ /dev/null
@@ -1 +0,0 @@
-{{stub}}{{language|AutoHotKey V2}}
\ No newline at end of file
diff --git a/Lang/AutoHotKey-V2/00-META.yaml b/Lang/AutoHotKey-V2/00-META.yaml
deleted file mode 100644
index 316ebe0ccb..0000000000
--- a/Lang/AutoHotKey-V2/00-META.yaml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-from: http://rosettacode.org/wiki/Category:AutoHotKey_V2
diff --git a/Lang/AutoHotKey-V2/Hello-world-Graphical b/Lang/AutoHotKey-V2/Hello-world-Graphical
deleted file mode 120000
index 89783bc714..0000000000
--- a/Lang/AutoHotKey-V2/Hello-world-Graphical
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Hello-world-Graphical/AutoHotKey-V2
\ No newline at end of file
diff --git a/Lang/Autohotkey-V2/00-LANG.txt b/Lang/Autohotkey-V2/00-LANG.txt
new file mode 100644
index 0000000000..b3e33b65ab
--- /dev/null
+++ b/Lang/Autohotkey-V2/00-LANG.txt
@@ -0,0 +1,16 @@
+{{stub}}AutoHotkey V2 is an [[open source]] programming language for Microsoft [[Windows]].
+
+AutoHotkey v2 is a major update to the AutoHotkey language, which includes numerous new features and improvements.
+
+== Citations ==
+
+* [https://www.autohotkey.com/docs/v2/ Documentation]
+* [http://autohotkey.com/download Downloads]
+* [http://autohotkey.com/docs/scripts/ Script Showcase]
+* [http://autohotkey.com/boards/ New Community forum]
+* [http://www.autohotkey.com/forum/ Archived Community forum]
+* [http://ahkscript.org/foundation AutoHotkey Foundation LLC]
+* [[wp:AutoHotkey|AutoHotkey on Wikipedia]]
+* #ahk on [http://webchat.freenode.net/?channels=%23ahk Freenode Web interface]
+* [[:Category:AutoHotkey_Originated]]
+{{language|Ayrch}}
\ No newline at end of file
diff --git a/Lang/Autohotkey-V2/00-META.yaml b/Lang/Autohotkey-V2/00-META.yaml
new file mode 100644
index 0000000000..651d1bc21b
--- /dev/null
+++ b/Lang/Autohotkey-V2/00-META.yaml
@@ -0,0 +1,2 @@
+---
+from: http://rosettacode.org/wiki/Category:Autohotkey_V2
diff --git a/Lang/Autohotkey-V2/Hello-world-Graphical b/Lang/Autohotkey-V2/Hello-world-Graphical
new file mode 120000
index 0000000000..0375a8eeb7
--- /dev/null
+++ b/Lang/Autohotkey-V2/Hello-world-Graphical
@@ -0,0 +1 @@
+../../Task/Hello-world-Graphical/Autohotkey-V2
\ No newline at end of file
diff --git a/Lang/BASIC/00-LANG.txt b/Lang/BASIC/00-LANG.txt
index 745f847ac8..ddee550d0d 100644
--- a/Lang/BASIC/00-LANG.txt
+++ b/Lang/BASIC/00-LANG.txt
@@ -37,6 +37,7 @@ BASIC became popular, with many different implementations for various computers.
***[[wp:Applesoft BASIC]]
***[[wp:Atari Microsoft BASIC]]
***[[wp:Commodore BASIC]]
+***[[wp:Extended Color BASIC]]
***[[wp:IBM BASIC]]
***[[wp:MS BASIC for Macintosh]]
***[[wp:MSX BASIC]]
diff --git a/Lang/BASIC/Arithmetic-derivative b/Lang/BASIC/Arithmetic-derivative
new file mode 120000
index 0000000000..25cf9a8b6a
--- /dev/null
+++ b/Lang/BASIC/Arithmetic-derivative
@@ -0,0 +1 @@
+../../Task/Arithmetic-derivative/BASIC
\ No newline at end of file
diff --git a/Lang/BASIC/Temperature-conversion b/Lang/BASIC/Temperature-conversion
deleted file mode 120000
index 21182b0539..0000000000
--- a/Lang/BASIC/Temperature-conversion
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Temperature-conversion/BASIC
\ No newline at end of file
diff --git a/Lang/BQN/Bell-numbers b/Lang/BQN/Bell-numbers
new file mode 120000
index 0000000000..2c520a34e3
--- /dev/null
+++ b/Lang/BQN/Bell-numbers
@@ -0,0 +1 @@
+../../Task/Bell-numbers/BQN
\ No newline at end of file
diff --git a/Lang/BQN/Call-an-object-method b/Lang/BQN/Call-an-object-method
new file mode 120000
index 0000000000..eb9e8d9920
--- /dev/null
+++ b/Lang/BQN/Call-an-object-method
@@ -0,0 +1 @@
+../../Task/Call-an-object-method/BQN
\ No newline at end of file
diff --git a/Lang/BQN/I-before-E-except-after-C b/Lang/BQN/I-before-E-except-after-C
new file mode 120000
index 0000000000..5fd82fbd92
--- /dev/null
+++ b/Lang/BQN/I-before-E-except-after-C
@@ -0,0 +1 @@
+../../Task/I-before-E-except-after-C/BQN
\ No newline at end of file
diff --git a/Lang/Basic09/00-LANG.txt b/Lang/Basic09/00-LANG.txt
index 16853881ce..fa600ca16b 100644
--- a/Lang/Basic09/00-LANG.txt
+++ b/Lang/Basic09/00-LANG.txt
@@ -1 +1,3 @@
-{{language|Basic09}}Basic09 is a dialect of BASIC created by Microware Systems Corporation in 1978 for use on the OS-9 operating system designed for the Motorola 6809 microporcessor. There is a version for OS-9/68000, "Microware BASIC", identical save that the INTEGER type is a four-byte signed integer instead of two-byte and REAL is IEEE 754 double precision rather than the five-byte format in the original version.
\ No newline at end of file
+{{language|Basic09}}
+{{implementation|BASIC}}
+Basic09 is a dialect of BASIC created by Microware Systems Corporation in 1978 for use on the OS-9 operating system designed for the Motorola 6809 microporcessor. There is a version for OS-9/68000, "Microware BASIC", identical save that the INTEGER type is a four-byte signed integer instead of two-byte and REAL is IEEE 754 double precision rather than the five-byte format in the original version.
\ No newline at end of file
diff --git a/Lang/Blade/00-LANG.txt b/Lang/Blade/00-LANG.txt
index f18c210bc3..71d6c9cdba 100644
--- a/Lang/Blade/00-LANG.txt
+++ b/Lang/Blade/00-LANG.txt
@@ -6,25 +6,13 @@
|parampass=value
|LCT=yes}}{{language programming paradigm|Object-oriented}}{{language programming paradigm|functional}}
-'''Blade''' is a simple, fast, clean and dynamic language that allows you to develop complex applications quickly. Blade emphasises algorithm over syntax and for this reason, it has a very small but powerful syntax set with a very natural feel.
+'''Blade''' is a modern general-purpose programming language focused on enterprise Web, IoT, and secure application development. '''Blade''' offers a comprehensive set of tools and libraries out of the box leading to reduced reliance on third-party packages.
-If you’ve ever had experience with a compiled language (e.g. [[C]]/[[C++]], [[Java]], etc), then one thing you’ll quickly notice (at least I did) was how much the whole process of write-compile-run-debug can be tedious and get in the way of creative programming and sometimes you even forget that mind-blowing algorithm you were going to write and take over the world in the whole process of compiling.
+'''Blade''' comes equipped with an integrated package management system, simplifying the management of both internal and external dependencies and a self-hostable repository server making it ideal for private organisational and personal use. Its intuitive syntax and gentle learning curve ensure an accessible experience for developers of all skill levels. Leveraging the best features from JavaScript, Python, Ruby, and Dart, '''Blade''' provides a familiar and robust ecosystem that enables developers to harness the strengths of these languages effortlessly.
-Sometimes, you just want to automate a few tasks, for example, I have a simple program to always remind me to get away from my laptop and eat something (you know how it is) and yet another one to suggest food for me. Do you find yourself needing this often? Do you know why you haven’t written it? Get out of your head, you are writing a compiled language! Compiling takes longer than the time it will take you to convince yourself that you need to eat.
-
-At other times, you have written this amazing program and you want users to be able to control it using a simple scripting language. I know… I know… there are many interpreted languages out there that will do the job just fine. Well… you still have one problem. Your users aren’t going to remember all the crazy going on in many of them (Yes [[Lua]]! I’m staring at you. What you gonna do about it?)
-
-Other times, we kind of find a very good solution to our problem in languages like [[Python]] (I must confess, even '''Blade''' did learn a lot of things from it), but the structure of such languages usually creates a new overhead in writing complex programs. It’s really difficult keeping a tab of indentations in such languages especially when you are not in a GUI IDE environment. I tried to work [[Python]] in nano, but man… it wasn’t easy.
-
-If you are feeling me, then Blade is just right for you.
-
-Blade is a simple language that has tried very much to learn from the mistake and successes of its predecessors.
-
-Blade is interpreted and simple like [[Python]] but with a more generic [[C]]-like syntax and a ridiculously simple Object-orientation similar to [[Dart]] and the granularity of [[JavaScript]] while still maintaining a very minimal syntax and keywords when compared to all of them.
-
-'''Blade is designed to be a memorizable language and the entire “language” can be learned in one sitting. However, Blade is as complete and powerful as any language can be and can be applied in the field of web, mobile, desktop, scientific, academic and research engineering to mention a few.'''
+While '''Blade''' focuses on Web and IoT, it is also great for general software development.
==Links==
-* [https://bladelang.com https://bladelang.com]
+* [https://bladelang.org https://bladelang.org]
* [https://github.com/blade-lang/blade https://github.com/blade-lang/blade]
-* [https://bladelang.com/quick-learn.html Quick Language Introduction]
\ No newline at end of file
+* [https://bladelang.org/quick-learn.html Quick Language Introduction]
\ No newline at end of file
diff --git a/Lang/C-sharp/Periodic-table b/Lang/C-sharp/Periodic-table
new file mode 120000
index 0000000000..97d676b17d
--- /dev/null
+++ b/Lang/C-sharp/Periodic-table
@@ -0,0 +1 @@
+../../Task/Periodic-table/C-sharp
\ No newline at end of file
diff --git a/Lang/CLU/Arithmetic-derivative b/Lang/CLU/Arithmetic-derivative
new file mode 120000
index 0000000000..f0f81c6bc1
--- /dev/null
+++ b/Lang/CLU/Arithmetic-derivative
@@ -0,0 +1 @@
+../../Task/Arithmetic-derivative/CLU
\ No newline at end of file
diff --git a/Lang/Chipmunk-Basic/ASCII-art-diagram-converter b/Lang/Chipmunk-Basic/ASCII-art-diagram-converter
new file mode 120000
index 0000000000..a034d74b58
--- /dev/null
+++ b/Lang/Chipmunk-Basic/ASCII-art-diagram-converter
@@ -0,0 +1 @@
+../../Task/ASCII-art-diagram-converter/Chipmunk-Basic
\ No newline at end of file
diff --git a/Lang/Chipmunk-Basic/Generate-Chess960-starting-position b/Lang/Chipmunk-Basic/Generate-Chess960-starting-position
new file mode 120000
index 0000000000..daceb0cf8f
--- /dev/null
+++ b/Lang/Chipmunk-Basic/Generate-Chess960-starting-position
@@ -0,0 +1 @@
+../../Task/Generate-Chess960-starting-position/Chipmunk-Basic
\ No newline at end of file
diff --git a/Lang/Commodore-BASIC/Random-number-generator-device- b/Lang/Commodore-BASIC/Random-number-generator-device-
new file mode 120000
index 0000000000..f23b1d0d42
--- /dev/null
+++ b/Lang/Commodore-BASIC/Random-number-generator-device-
@@ -0,0 +1 @@
+../../Task/Random-number-generator-device-/Commodore-BASIC
\ No newline at end of file
diff --git a/Lang/Cowgol/Align-columns b/Lang/Cowgol/Align-columns
new file mode 120000
index 0000000000..2931644d20
--- /dev/null
+++ b/Lang/Cowgol/Align-columns
@@ -0,0 +1 @@
+../../Task/Align-columns/Cowgol
\ No newline at end of file
diff --git a/Lang/Cowgol/Arithmetic-derivative b/Lang/Cowgol/Arithmetic-derivative
new file mode 120000
index 0000000000..5d9cc4afd2
--- /dev/null
+++ b/Lang/Cowgol/Arithmetic-derivative
@@ -0,0 +1 @@
+../../Task/Arithmetic-derivative/Cowgol
\ No newline at end of file
diff --git a/Lang/Crystal/00-LANG.txt b/Lang/Crystal/00-LANG.txt
index b671a267bf..365be4df5f 100644
--- a/Lang/Crystal/00-LANG.txt
+++ b/Lang/Crystal/00-LANG.txt
@@ -14,4 +14,7 @@ Crystal is a programming language with the following goals:
* Have compile-time evaluation and generation of code, to avoid boilerplate code.
* Compile to efficient native code.
-You can ask for help on Freenode in the #crystal-lang channel.
\ No newline at end of file
+You can ask for help on LiberaChat in the [ircs://irc.libera.chat:6697#crystal-lang #crystal-lang] channel ([https://web.libera.chat/#crystal-lang web]).
+
+==Tasks not implemented in Crystal==
+[[Tasks not implemented in Crystal]]
\ No newline at end of file
diff --git a/Lang/Crystal/Abbreviations-automatic b/Lang/Crystal/Abbreviations-automatic
new file mode 120000
index 0000000000..356658ce4c
--- /dev/null
+++ b/Lang/Crystal/Abbreviations-automatic
@@ -0,0 +1 @@
+../../Task/Abbreviations-automatic/Crystal
\ No newline at end of file
diff --git a/Lang/Crystal/Archimedean-spiral b/Lang/Crystal/Archimedean-spiral
new file mode 120000
index 0000000000..38cdafc563
--- /dev/null
+++ b/Lang/Crystal/Archimedean-spiral
@@ -0,0 +1 @@
+../../Task/Archimedean-spiral/Crystal
\ No newline at end of file
diff --git a/Lang/Crystal/Colour-bars-Display b/Lang/Crystal/Colour-bars-Display
new file mode 120000
index 0000000000..0ec7f62738
--- /dev/null
+++ b/Lang/Crystal/Colour-bars-Display
@@ -0,0 +1 @@
+../../Task/Colour-bars-Display/Crystal
\ No newline at end of file
diff --git a/Lang/Crystal/Enumerations b/Lang/Crystal/Enumerations
new file mode 120000
index 0000000000..81276f7ab4
--- /dev/null
+++ b/Lang/Crystal/Enumerations
@@ -0,0 +1 @@
+../../Task/Enumerations/Crystal
\ No newline at end of file
diff --git a/Lang/Crystal/Evolutionary-algorithm b/Lang/Crystal/Evolutionary-algorithm
new file mode 120000
index 0000000000..a0bcba6242
--- /dev/null
+++ b/Lang/Crystal/Evolutionary-algorithm
@@ -0,0 +1 @@
+../../Task/Evolutionary-algorithm/Crystal
\ No newline at end of file
diff --git a/Lang/Crystal/Letter-frequency b/Lang/Crystal/Letter-frequency
new file mode 120000
index 0000000000..9aed428d1c
--- /dev/null
+++ b/Lang/Crystal/Letter-frequency
@@ -0,0 +1 @@
+../../Task/Letter-frequency/Crystal
\ No newline at end of file
diff --git a/Lang/Crystal/Stem-and-leaf-plot b/Lang/Crystal/Stem-and-leaf-plot
new file mode 120000
index 0000000000..4fac378f12
--- /dev/null
+++ b/Lang/Crystal/Stem-and-leaf-plot
@@ -0,0 +1 @@
+../../Task/Stem-and-leaf-plot/Crystal
\ No newline at end of file
diff --git a/Lang/Crystal/Sudan-function b/Lang/Crystal/Sudan-function
new file mode 120000
index 0000000000..a75bf5defc
--- /dev/null
+++ b/Lang/Crystal/Sudan-function
@@ -0,0 +1 @@
+../../Task/Sudan-function/Crystal
\ No newline at end of file
diff --git a/Lang/Crystal/Textonyms b/Lang/Crystal/Textonyms
new file mode 120000
index 0000000000..e9c8a3c5ec
--- /dev/null
+++ b/Lang/Crystal/Textonyms
@@ -0,0 +1 @@
+../../Task/Textonyms/Crystal
\ No newline at end of file
diff --git a/Lang/Dart/Character-codes b/Lang/Dart/Character-codes
new file mode 120000
index 0000000000..eee070c4f5
--- /dev/null
+++ b/Lang/Dart/Character-codes
@@ -0,0 +1 @@
+../../Task/Character-codes/Dart
\ No newline at end of file
diff --git a/Lang/Draco/Align-columns b/Lang/Draco/Align-columns
new file mode 120000
index 0000000000..00c426b153
--- /dev/null
+++ b/Lang/Draco/Align-columns
@@ -0,0 +1 @@
+../../Task/Align-columns/Draco
\ No newline at end of file
diff --git a/Lang/Draco/Arithmetic-derivative b/Lang/Draco/Arithmetic-derivative
new file mode 120000
index 0000000000..b83ffadf85
--- /dev/null
+++ b/Lang/Draco/Arithmetic-derivative
@@ -0,0 +1 @@
+../../Task/Arithmetic-derivative/Draco
\ No newline at end of file
diff --git a/Lang/Draco/Doomsday-rule b/Lang/Draco/Doomsday-rule
new file mode 120000
index 0000000000..50f248643e
--- /dev/null
+++ b/Lang/Draco/Doomsday-rule
@@ -0,0 +1 @@
+../../Task/Doomsday-rule/Draco
\ No newline at end of file
diff --git a/Lang/Draco/Horners-rule-for-polynomial-evaluation b/Lang/Draco/Horners-rule-for-polynomial-evaluation
new file mode 120000
index 0000000000..3be037b7e6
--- /dev/null
+++ b/Lang/Draco/Horners-rule-for-polynomial-evaluation
@@ -0,0 +1 @@
+../../Task/Horners-rule-for-polynomial-evaluation/Draco
\ No newline at end of file
diff --git a/Lang/Draco/Roman-numerals-Encode b/Lang/Draco/Roman-numerals-Encode
new file mode 120000
index 0000000000..11eed87fb8
--- /dev/null
+++ b/Lang/Draco/Roman-numerals-Encode
@@ -0,0 +1 @@
+../../Task/Roman-numerals-Encode/Draco
\ No newline at end of file
diff --git a/Lang/Draco/Tokenize-a-string b/Lang/Draco/Tokenize-a-string
new file mode 120000
index 0000000000..b60ddd21df
--- /dev/null
+++ b/Lang/Draco/Tokenize-a-string
@@ -0,0 +1 @@
+../../Task/Tokenize-a-string/Draco
\ No newline at end of file
diff --git a/Lang/EDSAC-order-code/Shoelace-formula-for-polygonal-area b/Lang/EDSAC-order-code/Shoelace-formula-for-polygonal-area
new file mode 120000
index 0000000000..fb3446e1bf
--- /dev/null
+++ b/Lang/EDSAC-order-code/Shoelace-formula-for-polygonal-area
@@ -0,0 +1 @@
+../../Task/Shoelace-formula-for-polygonal-area/EDSAC-order-code
\ No newline at end of file
diff --git a/Lang/EMal/Delegates b/Lang/EMal/Delegates
new file mode 120000
index 0000000000..5293d68109
--- /dev/null
+++ b/Lang/EMal/Delegates
@@ -0,0 +1 @@
+../../Task/Delegates/EMal
\ No newline at end of file
diff --git a/Lang/EMal/Gamma-function b/Lang/EMal/Gamma-function
new file mode 120000
index 0000000000..f928139952
--- /dev/null
+++ b/Lang/EMal/Gamma-function
@@ -0,0 +1 @@
+../../Task/Gamma-function/EMal
\ No newline at end of file
diff --git a/Lang/EMal/Guess-the-number b/Lang/EMal/Guess-the-number
new file mode 120000
index 0000000000..fc6e3366e6
--- /dev/null
+++ b/Lang/EMal/Guess-the-number
@@ -0,0 +1 @@
+../../Task/Guess-the-number/EMal
\ No newline at end of file
diff --git a/Lang/EMal/Sudan-function b/Lang/EMal/Sudan-function
new file mode 120000
index 0000000000..ea87f1432e
--- /dev/null
+++ b/Lang/EMal/Sudan-function
@@ -0,0 +1 @@
+../../Task/Sudan-function/EMal
\ No newline at end of file
diff --git a/Lang/EMal/Ternary-logic b/Lang/EMal/Ternary-logic
new file mode 120000
index 0000000000..837bedfab5
--- /dev/null
+++ b/Lang/EMal/Ternary-logic
@@ -0,0 +1 @@
+../../Task/Ternary-logic/EMal
\ No newline at end of file
diff --git a/Lang/EasyLang/Bitmap-B-zier-curves-Quadratic b/Lang/EasyLang/Bitmap-B-zier-curves-Quadratic
new file mode 120000
index 0000000000..569a661356
--- /dev/null
+++ b/Lang/EasyLang/Bitmap-B-zier-curves-Quadratic
@@ -0,0 +1 @@
+../../Task/Bitmap-B-zier-curves-Quadratic/EasyLang
\ No newline at end of file
diff --git a/Lang/EasyLang/Fractran b/Lang/EasyLang/Fractran
new file mode 120000
index 0000000000..431453ab79
--- /dev/null
+++ b/Lang/EasyLang/Fractran
@@ -0,0 +1 @@
+../../Task/Fractran/EasyLang
\ No newline at end of file
diff --git a/Lang/EasyLang/Modified-random-distribution b/Lang/EasyLang/Modified-random-distribution
new file mode 120000
index 0000000000..127bc0bcb6
--- /dev/null
+++ b/Lang/EasyLang/Modified-random-distribution
@@ -0,0 +1 @@
+../../Task/Modified-random-distribution/EasyLang
\ No newline at end of file
diff --git a/Lang/EasyLang/Sort-an-outline-at-every-level b/Lang/EasyLang/Sort-an-outline-at-every-level
new file mode 120000
index 0000000000..aa549fd59a
--- /dev/null
+++ b/Lang/EasyLang/Sort-an-outline-at-every-level
@@ -0,0 +1 @@
+../../Task/Sort-an-outline-at-every-level/EasyLang
\ No newline at end of file
diff --git a/Lang/EasyLang/Square-free-integers b/Lang/EasyLang/Square-free-integers
new file mode 120000
index 0000000000..07046cee4c
--- /dev/null
+++ b/Lang/EasyLang/Square-free-integers
@@ -0,0 +1 @@
+../../Task/Square-free-integers/EasyLang
\ No newline at end of file
diff --git a/Lang/EasyLang/URL-encoding b/Lang/EasyLang/URL-encoding
new file mode 120000
index 0000000000..c0b065b1e5
--- /dev/null
+++ b/Lang/EasyLang/URL-encoding
@@ -0,0 +1 @@
+../../Task/URL-encoding/EasyLang
\ No newline at end of file
diff --git a/Lang/EasyLang/Universal-Turing-machine b/Lang/EasyLang/Universal-Turing-machine
new file mode 120000
index 0000000000..c6c36c7e83
--- /dev/null
+++ b/Lang/EasyLang/Universal-Turing-machine
@@ -0,0 +1 @@
+../../Task/Universal-Turing-machine/EasyLang
\ No newline at end of file
diff --git a/Lang/Emacs-Lisp/Align-columns b/Lang/Emacs-Lisp/Align-columns
new file mode 120000
index 0000000000..9be61160c6
--- /dev/null
+++ b/Lang/Emacs-Lisp/Align-columns
@@ -0,0 +1 @@
+../../Task/Align-columns/Emacs-Lisp
\ No newline at end of file
diff --git a/Lang/F-Sharp/Probabilistic-choice b/Lang/F-Sharp/Probabilistic-choice
new file mode 120000
index 0000000000..b7d2692fe4
--- /dev/null
+++ b/Lang/F-Sharp/Probabilistic-choice
@@ -0,0 +1 @@
+../../Task/Probabilistic-choice/F-Sharp
\ No newline at end of file
diff --git a/Lang/Forth/Bell-numbers b/Lang/Forth/Bell-numbers
new file mode 120000
index 0000000000..d0f973798a
--- /dev/null
+++ b/Lang/Forth/Bell-numbers
@@ -0,0 +1 @@
+../../Task/Bell-numbers/Forth
\ No newline at end of file
diff --git a/Lang/Forth/Deceptive-numbers b/Lang/Forth/Deceptive-numbers
new file mode 120000
index 0000000000..68978661e4
--- /dev/null
+++ b/Lang/Forth/Deceptive-numbers
@@ -0,0 +1 @@
+../../Task/Deceptive-numbers/Forth
\ No newline at end of file
diff --git a/Lang/Forth/Duffinian-numbers b/Lang/Forth/Duffinian-numbers
new file mode 120000
index 0000000000..9a7e28500f
--- /dev/null
+++ b/Lang/Forth/Duffinian-numbers
@@ -0,0 +1 @@
+../../Task/Duffinian-numbers/Forth
\ No newline at end of file
diff --git a/Lang/Forth/Fibonacci-word b/Lang/Forth/Fibonacci-word
new file mode 120000
index 0000000000..b5b4488597
--- /dev/null
+++ b/Lang/Forth/Fibonacci-word
@@ -0,0 +1 @@
+../../Task/Fibonacci-word/Forth
\ No newline at end of file
diff --git a/Lang/Forth/GUI-component-interaction b/Lang/Forth/GUI-component-interaction
new file mode 120000
index 0000000000..6ac944b586
--- /dev/null
+++ b/Lang/Forth/GUI-component-interaction
@@ -0,0 +1 @@
+../../Task/GUI-component-interaction/Forth
\ No newline at end of file
diff --git a/Lang/Forth/Lah-numbers b/Lang/Forth/Lah-numbers
new file mode 120000
index 0000000000..63faba81d9
--- /dev/null
+++ b/Lang/Forth/Lah-numbers
@@ -0,0 +1 @@
+../../Task/Lah-numbers/Forth
\ No newline at end of file
diff --git a/Lang/Forth/Leonardo-numbers b/Lang/Forth/Leonardo-numbers
new file mode 120000
index 0000000000..5742a06693
--- /dev/null
+++ b/Lang/Forth/Leonardo-numbers
@@ -0,0 +1 @@
+../../Task/Leonardo-numbers/Forth
\ No newline at end of file
diff --git a/Lang/Forth/M-bius-function b/Lang/Forth/M-bius-function
new file mode 120000
index 0000000000..02d70b9302
--- /dev/null
+++ b/Lang/Forth/M-bius-function
@@ -0,0 +1 @@
+../../Task/M-bius-function/Forth
\ No newline at end of file
diff --git a/Lang/Forth/Sorting-algorithms-Pancake-sort b/Lang/Forth/Sorting-algorithms-Pancake-sort
new file mode 120000
index 0000000000..84e38b0321
--- /dev/null
+++ b/Lang/Forth/Sorting-algorithms-Pancake-sort
@@ -0,0 +1 @@
+../../Task/Sorting-algorithms-Pancake-sort/Forth
\ No newline at end of file
diff --git a/Lang/Forth/Stirling-numbers-of-the-first-kind b/Lang/Forth/Stirling-numbers-of-the-first-kind
new file mode 120000
index 0000000000..f35ec2aaf5
--- /dev/null
+++ b/Lang/Forth/Stirling-numbers-of-the-first-kind
@@ -0,0 +1 @@
+../../Task/Stirling-numbers-of-the-first-kind/Forth
\ No newline at end of file
diff --git a/Lang/Forth/Stirling-numbers-of-the-second-kind b/Lang/Forth/Stirling-numbers-of-the-second-kind
new file mode 120000
index 0000000000..a86eb5dfc1
--- /dev/null
+++ b/Lang/Forth/Stirling-numbers-of-the-second-kind
@@ -0,0 +1 @@
+../../Task/Stirling-numbers-of-the-second-kind/Forth
\ No newline at end of file
diff --git a/Lang/Forth/Twin-primes b/Lang/Forth/Twin-primes
new file mode 120000
index 0000000000..7812aac04a
--- /dev/null
+++ b/Lang/Forth/Twin-primes
@@ -0,0 +1 @@
+../../Task/Twin-primes/Forth
\ No newline at end of file
diff --git a/Lang/Fortran/Additive-primes b/Lang/Fortran/Additive-primes
new file mode 120000
index 0000000000..ea531b1d68
--- /dev/null
+++ b/Lang/Fortran/Additive-primes
@@ -0,0 +1 @@
+../../Task/Additive-primes/Fortran
\ No newline at end of file
diff --git a/Lang/Fortran/Blum-integer b/Lang/Fortran/Blum-integer
new file mode 120000
index 0000000000..814d829eed
--- /dev/null
+++ b/Lang/Fortran/Blum-integer
@@ -0,0 +1 @@
+../../Task/Blum-integer/Fortran
\ No newline at end of file
diff --git a/Lang/Fortran/Burrows-Wheeler-transform b/Lang/Fortran/Burrows-Wheeler-transform
new file mode 120000
index 0000000000..e312b27f94
--- /dev/null
+++ b/Lang/Fortran/Burrows-Wheeler-transform
@@ -0,0 +1 @@
+../../Task/Burrows-Wheeler-transform/Fortran
\ No newline at end of file
diff --git a/Lang/Fortran/Chaocipher b/Lang/Fortran/Chaocipher
new file mode 120000
index 0000000000..1db3092120
--- /dev/null
+++ b/Lang/Fortran/Chaocipher
@@ -0,0 +1 @@
+../../Task/Chaocipher/Fortran
\ No newline at end of file
diff --git a/Lang/Fortran/Ranking-methods b/Lang/Fortran/Ranking-methods
new file mode 120000
index 0000000000..a369cc6fab
--- /dev/null
+++ b/Lang/Fortran/Ranking-methods
@@ -0,0 +1 @@
+../../Task/Ranking-methods/Fortran
\ No newline at end of file
diff --git a/Lang/Fortran/Strip-whitespace-from-a-string-Top-and-tail b/Lang/Fortran/Strip-whitespace-from-a-string-Top-and-tail
new file mode 120000
index 0000000000..e6e0c4696a
--- /dev/null
+++ b/Lang/Fortran/Strip-whitespace-from-a-string-Top-and-tail
@@ -0,0 +1 @@
+../../Task/Strip-whitespace-from-a-string-Top-and-tail/Fortran
\ No newline at end of file
diff --git a/Lang/Fortran/Vigen-re-cipher-Cryptanalysis b/Lang/Fortran/Vigen-re-cipher-Cryptanalysis
new file mode 120000
index 0000000000..1fbd3a2ec4
--- /dev/null
+++ b/Lang/Fortran/Vigen-re-cipher-Cryptanalysis
@@ -0,0 +1 @@
+../../Task/Vigen-re-cipher-Cryptanalysis/Fortran
\ No newline at end of file
diff --git a/Lang/Free-Pascal-Lazarus/Binary-strings b/Lang/Free-Pascal-Lazarus/Binary-strings
new file mode 120000
index 0000000000..f6ed90f24b
--- /dev/null
+++ b/Lang/Free-Pascal-Lazarus/Binary-strings
@@ -0,0 +1 @@
+../../Task/Binary-strings/Free-Pascal-Lazarus
\ No newline at end of file
diff --git a/Lang/Free-Pascal-Lazarus/Boyer-Moore-string-search b/Lang/Free-Pascal-Lazarus/Boyer-Moore-string-search
new file mode 120000
index 0000000000..9902c3a3ea
--- /dev/null
+++ b/Lang/Free-Pascal-Lazarus/Boyer-Moore-string-search
@@ -0,0 +1 @@
+../../Task/Boyer-Moore-string-search/Free-Pascal-Lazarus
\ No newline at end of file
diff --git a/Lang/Free-Pascal-Lazarus/Fractal-tree b/Lang/Free-Pascal-Lazarus/Fractal-tree
new file mode 120000
index 0000000000..c2081a0860
--- /dev/null
+++ b/Lang/Free-Pascal-Lazarus/Fractal-tree
@@ -0,0 +1 @@
+../../Task/Fractal-tree/Free-Pascal-Lazarus
\ No newline at end of file
diff --git a/Lang/Free-Pascal-Lazarus/Hickerson-series-of-almost-integers b/Lang/Free-Pascal-Lazarus/Hickerson-series-of-almost-integers
new file mode 120000
index 0000000000..e8c446d1f2
--- /dev/null
+++ b/Lang/Free-Pascal-Lazarus/Hickerson-series-of-almost-integers
@@ -0,0 +1 @@
+../../Task/Hickerson-series-of-almost-integers/Free-Pascal-Lazarus
\ No newline at end of file
diff --git a/Lang/Free-Pascal-Lazarus/Leonardo-numbers b/Lang/Free-Pascal-Lazarus/Leonardo-numbers
new file mode 120000
index 0000000000..5fc9b6dc54
--- /dev/null
+++ b/Lang/Free-Pascal-Lazarus/Leonardo-numbers
@@ -0,0 +1 @@
+../../Task/Leonardo-numbers/Free-Pascal-Lazarus
\ No newline at end of file
diff --git a/Lang/Free-Pascal-Lazarus/Ordered-words b/Lang/Free-Pascal-Lazarus/Ordered-words
new file mode 120000
index 0000000000..ec364f330e
--- /dev/null
+++ b/Lang/Free-Pascal-Lazarus/Ordered-words
@@ -0,0 +1 @@
+../../Task/Ordered-words/Free-Pascal-Lazarus
\ No newline at end of file
diff --git a/Lang/Free-Pascal-Lazarus/Probabilistic-choice b/Lang/Free-Pascal-Lazarus/Probabilistic-choice
new file mode 120000
index 0000000000..0f85f5937f
--- /dev/null
+++ b/Lang/Free-Pascal-Lazarus/Probabilistic-choice
@@ -0,0 +1 @@
+../../Task/Probabilistic-choice/Free-Pascal-Lazarus
\ No newline at end of file
diff --git a/Lang/Free-Pascal-Lazarus/Sorting-algorithms-Shell-sort b/Lang/Free-Pascal-Lazarus/Sorting-algorithms-Shell-sort
new file mode 120000
index 0000000000..e5c8120991
--- /dev/null
+++ b/Lang/Free-Pascal-Lazarus/Sorting-algorithms-Shell-sort
@@ -0,0 +1 @@
+../../Task/Sorting-algorithms-Shell-sort/Free-Pascal-Lazarus
\ No newline at end of file
diff --git a/Lang/FreeBASIC/24-game-Solve b/Lang/FreeBASIC/24-game-Solve
new file mode 120000
index 0000000000..68ad0335d9
--- /dev/null
+++ b/Lang/FreeBASIC/24-game-Solve
@@ -0,0 +1 @@
+../../Task/24-game-Solve/FreeBASIC
\ No newline at end of file
diff --git a/Lang/FreeBASIC/ASCII-art-diagram-converter b/Lang/FreeBASIC/ASCII-art-diagram-converter
new file mode 120000
index 0000000000..f349074235
--- /dev/null
+++ b/Lang/FreeBASIC/ASCII-art-diagram-converter
@@ -0,0 +1 @@
+../../Task/ASCII-art-diagram-converter/FreeBASIC
\ No newline at end of file
diff --git a/Lang/FreeBASIC/Arithmetic-derivative b/Lang/FreeBASIC/Arithmetic-derivative
new file mode 120000
index 0000000000..2a22a10780
--- /dev/null
+++ b/Lang/FreeBASIC/Arithmetic-derivative
@@ -0,0 +1 @@
+../../Task/Arithmetic-derivative/FreeBASIC
\ No newline at end of file
diff --git a/Lang/FreeBASIC/Bitmap-PPM-conversion-through-a-pipe b/Lang/FreeBASIC/Bitmap-PPM-conversion-through-a-pipe
new file mode 120000
index 0000000000..9082778f9e
--- /dev/null
+++ b/Lang/FreeBASIC/Bitmap-PPM-conversion-through-a-pipe
@@ -0,0 +1 @@
+../../Task/Bitmap-PPM-conversion-through-a-pipe/FreeBASIC
\ No newline at end of file
diff --git a/Lang/FreeBASIC/Bitmap-Read-an-image-through-a-pipe b/Lang/FreeBASIC/Bitmap-Read-an-image-through-a-pipe
new file mode 120000
index 0000000000..17dd1b6040
--- /dev/null
+++ b/Lang/FreeBASIC/Bitmap-Read-an-image-through-a-pipe
@@ -0,0 +1 @@
+../../Task/Bitmap-Read-an-image-through-a-pipe/FreeBASIC
\ No newline at end of file
diff --git a/Lang/FreeBASIC/Cyclotomic-polynomial b/Lang/FreeBASIC/Cyclotomic-polynomial
new file mode 120000
index 0000000000..82e1fdeb03
--- /dev/null
+++ b/Lang/FreeBASIC/Cyclotomic-polynomial
@@ -0,0 +1 @@
+../../Task/Cyclotomic-polynomial/FreeBASIC
\ No newline at end of file
diff --git a/Lang/FreeBASIC/Dijkstras-algorithm b/Lang/FreeBASIC/Dijkstras-algorithm
new file mode 120000
index 0000000000..4465c347e7
--- /dev/null
+++ b/Lang/FreeBASIC/Dijkstras-algorithm
@@ -0,0 +1 @@
+../../Task/Dijkstras-algorithm/FreeBASIC
\ No newline at end of file
diff --git a/Lang/FreeBASIC/Dining-philosophers b/Lang/FreeBASIC/Dining-philosophers
new file mode 120000
index 0000000000..5d616c69b5
--- /dev/null
+++ b/Lang/FreeBASIC/Dining-philosophers
@@ -0,0 +1 @@
+../../Task/Dining-philosophers/FreeBASIC
\ No newline at end of file
diff --git a/Lang/FreeBASIC/Distance-and-Bearing b/Lang/FreeBASIC/Distance-and-Bearing
new file mode 120000
index 0000000000..14b1500a35
--- /dev/null
+++ b/Lang/FreeBASIC/Distance-and-Bearing
@@ -0,0 +1 @@
+../../Task/Distance-and-Bearing/FreeBASIC
\ No newline at end of file
diff --git a/Lang/FreeBASIC/Four-is-the-number-of-letters-in-the-... b/Lang/FreeBASIC/Four-is-the-number-of-letters-in-the-...
new file mode 120000
index 0000000000..7c1f37136c
--- /dev/null
+++ b/Lang/FreeBASIC/Four-is-the-number-of-letters-in-the-...
@@ -0,0 +1 @@
+../../Task/Four-is-the-number-of-letters-in-the-.../FreeBASIC
\ No newline at end of file
diff --git a/Lang/FreeBASIC/HTTPS-Client-authenticated b/Lang/FreeBASIC/HTTPS-Client-authenticated
new file mode 120000
index 0000000000..8c2cbfcd86
--- /dev/null
+++ b/Lang/FreeBASIC/HTTPS-Client-authenticated
@@ -0,0 +1 @@
+../../Task/HTTPS-Client-authenticated/FreeBASIC
\ No newline at end of file
diff --git a/Lang/FreeBASIC/Inverted-index b/Lang/FreeBASIC/Inverted-index
new file mode 120000
index 0000000000..affc1bf23c
--- /dev/null
+++ b/Lang/FreeBASIC/Inverted-index
@@ -0,0 +1 @@
+../../Task/Inverted-index/FreeBASIC
\ No newline at end of file
diff --git a/Lang/FreeBASIC/Median-filter b/Lang/FreeBASIC/Median-filter
new file mode 120000
index 0000000000..a0d5eec8a2
--- /dev/null
+++ b/Lang/FreeBASIC/Median-filter
@@ -0,0 +1 @@
+../../Task/Median-filter/FreeBASIC
\ No newline at end of file
diff --git a/Lang/FreeBASIC/Multiplicative-order b/Lang/FreeBASIC/Multiplicative-order
new file mode 120000
index 0000000000..1ba98d9611
--- /dev/null
+++ b/Lang/FreeBASIC/Multiplicative-order
@@ -0,0 +1 @@
+../../Task/Multiplicative-order/FreeBASIC
\ No newline at end of file
diff --git a/Lang/FreeBASIC/Percolation-Bond-percolation b/Lang/FreeBASIC/Percolation-Bond-percolation
new file mode 120000
index 0000000000..15d6381502
--- /dev/null
+++ b/Lang/FreeBASIC/Percolation-Bond-percolation
@@ -0,0 +1 @@
+../../Task/Percolation-Bond-percolation/FreeBASIC
\ No newline at end of file
diff --git a/Lang/FreeBASIC/Primes---allocate-descendants-to-their-ancestors b/Lang/FreeBASIC/Primes---allocate-descendants-to-their-ancestors
new file mode 120000
index 0000000000..49848d0592
--- /dev/null
+++ b/Lang/FreeBASIC/Primes---allocate-descendants-to-their-ancestors
@@ -0,0 +1 @@
+../../Task/Primes---allocate-descendants-to-their-ancestors/FreeBASIC
\ No newline at end of file
diff --git a/Lang/FreeBASIC/S-expressions b/Lang/FreeBASIC/S-expressions
new file mode 120000
index 0000000000..9a014b780a
--- /dev/null
+++ b/Lang/FreeBASIC/S-expressions
@@ -0,0 +1 @@
+../../Task/S-expressions/FreeBASIC
\ No newline at end of file
diff --git a/Lang/FreeBASIC/Sisyphus-sequence b/Lang/FreeBASIC/Sisyphus-sequence
new file mode 120000
index 0000000000..10074b9571
--- /dev/null
+++ b/Lang/FreeBASIC/Sisyphus-sequence
@@ -0,0 +1 @@
+../../Task/Sisyphus-sequence/FreeBASIC
\ No newline at end of file
diff --git a/Lang/FreeBASIC/Sort-a-list-of-object-identifiers b/Lang/FreeBASIC/Sort-a-list-of-object-identifiers
new file mode 120000
index 0000000000..2c5a5fbb3b
--- /dev/null
+++ b/Lang/FreeBASIC/Sort-a-list-of-object-identifiers
@@ -0,0 +1 @@
+../../Task/Sort-a-list-of-object-identifiers/FreeBASIC
\ No newline at end of file
diff --git a/Lang/FreeBASIC/Sort-an-outline-at-every-level b/Lang/FreeBASIC/Sort-an-outline-at-every-level
new file mode 120000
index 0000000000..ae4c555049
--- /dev/null
+++ b/Lang/FreeBASIC/Sort-an-outline-at-every-level
@@ -0,0 +1 @@
+../../Task/Sort-an-outline-at-every-level/FreeBASIC
\ No newline at end of file
diff --git a/Lang/FreeBASIC/Sorting-algorithms-Radix-sort b/Lang/FreeBASIC/Sorting-algorithms-Radix-sort
new file mode 120000
index 0000000000..bddec7031b
--- /dev/null
+++ b/Lang/FreeBASIC/Sorting-algorithms-Radix-sort
@@ -0,0 +1 @@
+../../Task/Sorting-algorithms-Radix-sort/FreeBASIC
\ No newline at end of file
diff --git a/Lang/FreeBASIC/Topological-sort b/Lang/FreeBASIC/Topological-sort
new file mode 120000
index 0000000000..c6cd407c9f
--- /dev/null
+++ b/Lang/FreeBASIC/Topological-sort
@@ -0,0 +1 @@
+../../Task/Topological-sort/FreeBASIC
\ No newline at end of file
diff --git a/Lang/FreeBASIC/Truth-table b/Lang/FreeBASIC/Truth-table
new file mode 120000
index 0000000000..228be906c6
--- /dev/null
+++ b/Lang/FreeBASIC/Truth-table
@@ -0,0 +1 @@
+../../Task/Truth-table/FreeBASIC
\ No newline at end of file
diff --git a/Lang/FreeBASIC/Vigen-re-cipher-Cryptanalysis b/Lang/FreeBASIC/Vigen-re-cipher-Cryptanalysis
new file mode 120000
index 0000000000..a802341d36
--- /dev/null
+++ b/Lang/FreeBASIC/Vigen-re-cipher-Cryptanalysis
@@ -0,0 +1 @@
+../../Task/Vigen-re-cipher-Cryptanalysis/FreeBASIC
\ No newline at end of file
diff --git a/Lang/FreeBASIC/Web-scraping b/Lang/FreeBASIC/Web-scraping
deleted file mode 120000
index ef3ee370f4..0000000000
--- a/Lang/FreeBASIC/Web-scraping
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Web-scraping/FreeBASIC
\ No newline at end of file
diff --git a/Lang/FutureBasic/00-LANG.txt b/Lang/FutureBasic/00-LANG.txt
index d3dbdba2ec..36f5f0b065 100644
--- a/Lang/FutureBasic/00-LANG.txt
+++ b/Lang/FutureBasic/00-LANG.txt
@@ -12,7 +12,11 @@
[[File:FutureBasicIcon.png|64px|top]]
-FutureBasic began life as Zbasic, a commercial variant of [[BASIC]] for the early Macintoshes, but has grown far beyond that into a mature freeware IDE that, through its FBtoC translator, can be used to compile C and Objective-C [[object-oriented]] code using the clang compiler included with an Xcode installation. It is excellent as a educational tool and for fast prototyping -- especially in Objective-C (Cocoa) by those who prefer programmatic code without the overhead of Xcode. Among its enthusiasts are commercial developers, engineers, professors, doctors, musicians, writers and a host of amateurs who program with FB for the sheer joy of it.
+FutureBasic — commonly called FB by its users — is a robust freeware Macintosh IDE.
+
+It began life as Zbasic, a commercial variant of [[BASIC]] for the early Macintoshes, but has grown far beyond that into a mature IDE compatible with the latest macOSes. Through its FBtoC translator, it can be used to compile C and Objective-C [[object-oriented]] code. It uses the industry-standard clang compiler included with an Xcode installation.
+
+FB is excellent as a educational tool, for fast prototyping and for commercial application development. In addition to its native language, it can incorporate C and Objective-C (Cocoa) for those who prefer programmatic code without the overhead of Xcode. It is compatible with Xcode nib and xib files used for building GUIs. Among its enthusiasts are commercial developers, engineers, professors, doctors, musicians, writers and a host of amateurs who program with FB for the sheer joy of it.
== FutureBasic Home Page & Download ==
@@ -64,11 +68,11 @@ In 1995 Staz Software, led by Chris Stasny based in Diamondhead, Miss., acquired
When Apple transitioned the Mac from 68k to PowerPC, the FB editor was rewritten by Stasny and was coupled with an adaptation of the compiler by Andy Gariepy. The result of their efforts, a dramatically enhanced IDE called FB^3 (FB-cubed) was released in September 1999.
-Major update releases introduced a full-featured Appearance Compliant runtime written by the late New Zealander Robert Purves renown for his brilliant programming. Once completely carbonized to run natively on the Mac OS X, the FutureBASIC Integrated Development Environment (FB IDE) was called FB4 and released in July 2004.
+Major update releases introduced a full-featured Appearance Compliant runtime written by the late New Zealander Robert Purves renowned for his brilliant programming. Once completely carbonized to run natively on the Mac OS X, the FutureBASIC Integrated Development Environment (FB IDE) was called FB4 and released in July 2004.
In August 2005, Staz Software was devastated by Hurricane Katrina just at the time Apple was transitioning from Motorola PPC microprocessors to Intel chips. FB development slowed almost to a standstill. On January 1, 2008, Staz Software announced that FB would henceforth be freeware and FB4 with FBtoC 1.0 was made available.
-Since that time, an independent team of volunteer developers initially lead by Purves continued to improve FBtoC, which took code produced by the FB Editor and translated it to C for processing by gcc which was eventually transitioned to the more robust clang.
+Since that time, an independent team of volunteer developers initially led by Purves continued to improve FBtoC, which took code produced by the FB Editor and translated it to C for processing by gcc which was eventually transitioned to the more robust clang.
On Sunday, June 3, 2012, members of the FB List Serve were notified that Robert Purves had died after a long bout with cancer. The news came as a surprise to many FB developers who were unaware of Purves' illness. While coping with cancer, he continued as an active member of the FB community, improving FB, answering questions, solving problems, and posting exquisitely terse code often salted with pithy remarks from his wonderfully dry humor. He never mentioned his health problems and never complained. A tribute to Purves can be found at the bottom of the FB Home Page
diff --git a/Lang/FutureBasic/AKS-test-for-primes b/Lang/FutureBasic/AKS-test-for-primes
new file mode 120000
index 0000000000..d7fcaa6502
--- /dev/null
+++ b/Lang/FutureBasic/AKS-test-for-primes
@@ -0,0 +1 @@
+../../Task/AKS-test-for-primes/FutureBasic
\ No newline at end of file
diff --git a/Lang/FutureBasic/Achilles-numbers b/Lang/FutureBasic/Achilles-numbers
new file mode 120000
index 0000000000..a912859c01
--- /dev/null
+++ b/Lang/FutureBasic/Achilles-numbers
@@ -0,0 +1 @@
+../../Task/Achilles-numbers/FutureBasic
\ No newline at end of file
diff --git a/Lang/FutureBasic/Aliquot-sequence-classifications b/Lang/FutureBasic/Aliquot-sequence-classifications
new file mode 120000
index 0000000000..d24c82afdc
--- /dev/null
+++ b/Lang/FutureBasic/Aliquot-sequence-classifications
@@ -0,0 +1 @@
+../../Task/Aliquot-sequence-classifications/FutureBasic
\ No newline at end of file
diff --git a/Lang/FutureBasic/Angles-geometric-normalization-and-conversion b/Lang/FutureBasic/Angles-geometric-normalization-and-conversion
new file mode 120000
index 0000000000..63c4e835a4
--- /dev/null
+++ b/Lang/FutureBasic/Angles-geometric-normalization-and-conversion
@@ -0,0 +1 @@
+../../Task/Angles-geometric-normalization-and-conversion/FutureBasic
\ No newline at end of file
diff --git a/Lang/FutureBasic/Arithmetic-derivative b/Lang/FutureBasic/Arithmetic-derivative
new file mode 120000
index 0000000000..4b54c16b3d
--- /dev/null
+++ b/Lang/FutureBasic/Arithmetic-derivative
@@ -0,0 +1 @@
+../../Task/Arithmetic-derivative/FutureBasic
\ No newline at end of file
diff --git a/Lang/FutureBasic/Assertions b/Lang/FutureBasic/Assertions
new file mode 120000
index 0000000000..6270ababb4
--- /dev/null
+++ b/Lang/FutureBasic/Assertions
@@ -0,0 +1 @@
+../../Task/Assertions/FutureBasic
\ No newline at end of file
diff --git a/Lang/FutureBasic/Brownian-tree b/Lang/FutureBasic/Brownian-tree
new file mode 120000
index 0000000000..26e06861c7
--- /dev/null
+++ b/Lang/FutureBasic/Brownian-tree
@@ -0,0 +1 @@
+../../Task/Brownian-tree/FutureBasic
\ No newline at end of file
diff --git a/Lang/FutureBasic/Catalan-numbers-Pascals-triangle b/Lang/FutureBasic/Catalan-numbers-Pascals-triangle
new file mode 120000
index 0000000000..48a5bd3f8b
--- /dev/null
+++ b/Lang/FutureBasic/Catalan-numbers-Pascals-triangle
@@ -0,0 +1 @@
+../../Task/Catalan-numbers-Pascals-triangle/FutureBasic
\ No newline at end of file
diff --git a/Lang/FutureBasic/Command-line-arguments b/Lang/FutureBasic/Command-line-arguments
new file mode 120000
index 0000000000..2926af8716
--- /dev/null
+++ b/Lang/FutureBasic/Command-line-arguments
@@ -0,0 +1 @@
+../../Task/Command-line-arguments/FutureBasic
\ No newline at end of file
diff --git a/Lang/FutureBasic/Constrained-random-points-on-a-circle b/Lang/FutureBasic/Constrained-random-points-on-a-circle
new file mode 120000
index 0000000000..db1c784250
--- /dev/null
+++ b/Lang/FutureBasic/Constrained-random-points-on-a-circle
@@ -0,0 +1 @@
+../../Task/Constrained-random-points-on-a-circle/FutureBasic
\ No newline at end of file
diff --git a/Lang/FutureBasic/Death-Star b/Lang/FutureBasic/Death-Star
new file mode 120000
index 0000000000..6a87d38224
--- /dev/null
+++ b/Lang/FutureBasic/Death-Star
@@ -0,0 +1 @@
+../../Task/Death-Star/FutureBasic
\ No newline at end of file
diff --git a/Lang/FutureBasic/Digital-root b/Lang/FutureBasic/Digital-root
new file mode 120000
index 0000000000..63da54faf1
--- /dev/null
+++ b/Lang/FutureBasic/Digital-root
@@ -0,0 +1 @@
+../../Task/Digital-root/FutureBasic
\ No newline at end of file
diff --git a/Lang/FutureBasic/Dinesmans-multiple-dwelling-problem b/Lang/FutureBasic/Dinesmans-multiple-dwelling-problem
new file mode 120000
index 0000000000..cdb0294902
--- /dev/null
+++ b/Lang/FutureBasic/Dinesmans-multiple-dwelling-problem
@@ -0,0 +1 @@
+../../Task/Dinesmans-multiple-dwelling-problem/FutureBasic
\ No newline at end of file
diff --git a/Lang/FutureBasic/Doubly-linked-list-Definition b/Lang/FutureBasic/Doubly-linked-list-Definition
new file mode 120000
index 0000000000..dbb3fa0478
--- /dev/null
+++ b/Lang/FutureBasic/Doubly-linked-list-Definition
@@ -0,0 +1 @@
+../../Task/Doubly-linked-list-Definition/FutureBasic
\ No newline at end of file
diff --git a/Lang/FutureBasic/Eban-numbers b/Lang/FutureBasic/Eban-numbers
new file mode 120000
index 0000000000..2ae3f59434
--- /dev/null
+++ b/Lang/FutureBasic/Eban-numbers
@@ -0,0 +1 @@
+../../Task/Eban-numbers/FutureBasic
\ No newline at end of file
diff --git a/Lang/FutureBasic/Echo-server b/Lang/FutureBasic/Echo-server
new file mode 120000
index 0000000000..25d59262e7
--- /dev/null
+++ b/Lang/FutureBasic/Echo-server
@@ -0,0 +1 @@
+../../Task/Echo-server/FutureBasic
\ No newline at end of file
diff --git a/Lang/FutureBasic/Egyptian-division b/Lang/FutureBasic/Egyptian-division
new file mode 120000
index 0000000000..5961af2842
--- /dev/null
+++ b/Lang/FutureBasic/Egyptian-division
@@ -0,0 +1 @@
+../../Task/Egyptian-division/FutureBasic
\ No newline at end of file
diff --git a/Lang/FutureBasic/Entropy b/Lang/FutureBasic/Entropy
new file mode 120000
index 0000000000..6336540906
--- /dev/null
+++ b/Lang/FutureBasic/Entropy
@@ -0,0 +1 @@
+../../Task/Entropy/FutureBasic
\ No newline at end of file
diff --git a/Lang/FutureBasic/Evolutionary-algorithm b/Lang/FutureBasic/Evolutionary-algorithm
new file mode 120000
index 0000000000..6ad9576429
--- /dev/null
+++ b/Lang/FutureBasic/Evolutionary-algorithm
@@ -0,0 +1 @@
+../../Task/Evolutionary-algorithm/FutureBasic
\ No newline at end of file
diff --git a/Lang/FutureBasic/Fibonacci-word b/Lang/FutureBasic/Fibonacci-word
new file mode 120000
index 0000000000..c773eeed44
--- /dev/null
+++ b/Lang/FutureBasic/Fibonacci-word
@@ -0,0 +1 @@
+../../Task/Fibonacci-word/FutureBasic
\ No newline at end of file
diff --git a/Lang/FutureBasic/Find-the-missing-permutation b/Lang/FutureBasic/Find-the-missing-permutation
new file mode 120000
index 0000000000..83f97c5dbb
--- /dev/null
+++ b/Lang/FutureBasic/Find-the-missing-permutation
@@ -0,0 +1 @@
+../../Task/Find-the-missing-permutation/FutureBasic
\ No newline at end of file
diff --git a/Lang/FutureBasic/Flipping-bits-game b/Lang/FutureBasic/Flipping-bits-game
new file mode 120000
index 0000000000..439479c614
--- /dev/null
+++ b/Lang/FutureBasic/Flipping-bits-game
@@ -0,0 +1 @@
+../../Task/Flipping-bits-game/FutureBasic
\ No newline at end of file
diff --git a/Lang/FutureBasic/Gray-code b/Lang/FutureBasic/Gray-code
new file mode 120000
index 0000000000..5eafcaba04
--- /dev/null
+++ b/Lang/FutureBasic/Gray-code
@@ -0,0 +1 @@
+../../Task/Gray-code/FutureBasic
\ No newline at end of file
diff --git a/Lang/FutureBasic/HTTPS-Authenticated b/Lang/FutureBasic/HTTPS-Authenticated
new file mode 120000
index 0000000000..9edb1d8326
--- /dev/null
+++ b/Lang/FutureBasic/HTTPS-Authenticated
@@ -0,0 +1 @@
+../../Task/HTTPS-Authenticated/FutureBasic
\ No newline at end of file
diff --git a/Lang/FutureBasic/Halt-and-catch-fire b/Lang/FutureBasic/Halt-and-catch-fire
new file mode 120000
index 0000000000..d78c73210e
--- /dev/null
+++ b/Lang/FutureBasic/Halt-and-catch-fire
@@ -0,0 +1 @@
+../../Task/Halt-and-catch-fire/FutureBasic
\ No newline at end of file
diff --git a/Lang/FutureBasic/Hello-world-Standard-error b/Lang/FutureBasic/Hello-world-Standard-error
new file mode 120000
index 0000000000..326ae936a9
--- /dev/null
+++ b/Lang/FutureBasic/Hello-world-Standard-error
@@ -0,0 +1 @@
+../../Task/Hello-world-Standard-error/FutureBasic
\ No newline at end of file
diff --git a/Lang/FutureBasic/Here-document b/Lang/FutureBasic/Here-document
new file mode 120000
index 0000000000..44b4edadd8
--- /dev/null
+++ b/Lang/FutureBasic/Here-document
@@ -0,0 +1 @@
+../../Task/Here-document/FutureBasic
\ No newline at end of file
diff --git a/Lang/FutureBasic/Hofstadter-Q-sequence b/Lang/FutureBasic/Hofstadter-Q-sequence
new file mode 120000
index 0000000000..bb38370ecf
--- /dev/null
+++ b/Lang/FutureBasic/Hofstadter-Q-sequence
@@ -0,0 +1 @@
+../../Task/Hofstadter-Q-sequence/FutureBasic
\ No newline at end of file
diff --git a/Lang/FutureBasic/Hunt-the-Wumpus b/Lang/FutureBasic/Hunt-the-Wumpus
new file mode 120000
index 0000000000..6ac2d19ea6
--- /dev/null
+++ b/Lang/FutureBasic/Hunt-the-Wumpus
@@ -0,0 +1 @@
+../../Task/Hunt-the-Wumpus/FutureBasic
\ No newline at end of file
diff --git a/Lang/FutureBasic/Integer-overflow b/Lang/FutureBasic/Integer-overflow
new file mode 120000
index 0000000000..37f3cd9e93
--- /dev/null
+++ b/Lang/FutureBasic/Integer-overflow
@@ -0,0 +1 @@
+../../Task/Integer-overflow/FutureBasic
\ No newline at end of file
diff --git a/Lang/FutureBasic/Knights-tour b/Lang/FutureBasic/Knights-tour
new file mode 120000
index 0000000000..c40890eb0e
--- /dev/null
+++ b/Lang/FutureBasic/Knights-tour
@@ -0,0 +1 @@
+../../Task/Knights-tour/FutureBasic
\ No newline at end of file
diff --git a/Lang/FutureBasic/MAC-vendor-lookup b/Lang/FutureBasic/MAC-vendor-lookup
new file mode 120000
index 0000000000..63a0a7c0b7
--- /dev/null
+++ b/Lang/FutureBasic/MAC-vendor-lookup
@@ -0,0 +1 @@
+../../Task/MAC-vendor-lookup/FutureBasic
\ No newline at end of file
diff --git a/Lang/FutureBasic/Mastermind b/Lang/FutureBasic/Mastermind
new file mode 120000
index 0000000000..e02911b738
--- /dev/null
+++ b/Lang/FutureBasic/Mastermind
@@ -0,0 +1 @@
+../../Task/Mastermind/FutureBasic
\ No newline at end of file
diff --git a/Lang/FutureBasic/Mayan-calendar b/Lang/FutureBasic/Mayan-calendar
new file mode 120000
index 0000000000..7b5f78ca25
--- /dev/null
+++ b/Lang/FutureBasic/Mayan-calendar
@@ -0,0 +1 @@
+../../Task/Mayan-calendar/FutureBasic
\ No newline at end of file
diff --git a/Lang/FutureBasic/Minesweeper-game b/Lang/FutureBasic/Minesweeper-game
new file mode 120000
index 0000000000..fdc515bbc6
--- /dev/null
+++ b/Lang/FutureBasic/Minesweeper-game
@@ -0,0 +1 @@
+../../Task/Minesweeper-game/FutureBasic
\ No newline at end of file
diff --git a/Lang/FutureBasic/Pascals-triangle b/Lang/FutureBasic/Pascals-triangle
new file mode 120000
index 0000000000..31e8218285
--- /dev/null
+++ b/Lang/FutureBasic/Pascals-triangle
@@ -0,0 +1 @@
+../../Task/Pascals-triangle/FutureBasic
\ No newline at end of file
diff --git a/Lang/FutureBasic/Pentagram b/Lang/FutureBasic/Pentagram
new file mode 120000
index 0000000000..036f2d484a
--- /dev/null
+++ b/Lang/FutureBasic/Pentagram
@@ -0,0 +1 @@
+../../Task/Pentagram/FutureBasic
\ No newline at end of file
diff --git a/Lang/FutureBasic/Poker-hand-analyser b/Lang/FutureBasic/Poker-hand-analyser
new file mode 120000
index 0000000000..35dd2acb93
--- /dev/null
+++ b/Lang/FutureBasic/Poker-hand-analyser
@@ -0,0 +1 @@
+../../Task/Poker-hand-analyser/FutureBasic
\ No newline at end of file
diff --git a/Lang/FutureBasic/Range-expansion b/Lang/FutureBasic/Range-expansion
new file mode 120000
index 0000000000..9b92918178
--- /dev/null
+++ b/Lang/FutureBasic/Range-expansion
@@ -0,0 +1 @@
+../../Task/Range-expansion/FutureBasic
\ No newline at end of file
diff --git a/Lang/FutureBasic/Range-extraction b/Lang/FutureBasic/Range-extraction
new file mode 120000
index 0000000000..9a5f1d0533
--- /dev/null
+++ b/Lang/FutureBasic/Range-extraction
@@ -0,0 +1 @@
+../../Task/Range-extraction/FutureBasic
\ No newline at end of file
diff --git a/Lang/FutureBasic/Resistor-mesh b/Lang/FutureBasic/Resistor-mesh
new file mode 120000
index 0000000000..318a1a0f13
--- /dev/null
+++ b/Lang/FutureBasic/Resistor-mesh
@@ -0,0 +1 @@
+../../Task/Resistor-mesh/FutureBasic
\ No newline at end of file
diff --git a/Lang/FutureBasic/SHA-256 b/Lang/FutureBasic/SHA-256
new file mode 120000
index 0000000000..0d14776e97
--- /dev/null
+++ b/Lang/FutureBasic/SHA-256
@@ -0,0 +1 @@
+../../Task/SHA-256/FutureBasic
\ No newline at end of file
diff --git a/Lang/FutureBasic/Semordnilap b/Lang/FutureBasic/Semordnilap
new file mode 120000
index 0000000000..23f6715ad0
--- /dev/null
+++ b/Lang/FutureBasic/Semordnilap
@@ -0,0 +1 @@
+../../Task/Semordnilap/FutureBasic
\ No newline at end of file
diff --git a/Lang/FutureBasic/Sierpinski-carpet b/Lang/FutureBasic/Sierpinski-carpet
new file mode 120000
index 0000000000..c79bb878a8
--- /dev/null
+++ b/Lang/FutureBasic/Sierpinski-carpet
@@ -0,0 +1 @@
+../../Task/Sierpinski-carpet/FutureBasic
\ No newline at end of file
diff --git a/Lang/FutureBasic/Sort-disjoint-sublist b/Lang/FutureBasic/Sort-disjoint-sublist
new file mode 120000
index 0000000000..030bf0bfd7
--- /dev/null
+++ b/Lang/FutureBasic/Sort-disjoint-sublist
@@ -0,0 +1 @@
+../../Task/Sort-disjoint-sublist/FutureBasic
\ No newline at end of file
diff --git a/Lang/FutureBasic/Spiral-matrix b/Lang/FutureBasic/Spiral-matrix
new file mode 120000
index 0000000000..4d24174200
--- /dev/null
+++ b/Lang/FutureBasic/Spiral-matrix
@@ -0,0 +1 @@
+../../Task/Spiral-matrix/FutureBasic
\ No newline at end of file
diff --git a/Lang/FutureBasic/Strip-block-comments b/Lang/FutureBasic/Strip-block-comments
new file mode 120000
index 0000000000..1f0c4fb53d
--- /dev/null
+++ b/Lang/FutureBasic/Strip-block-comments
@@ -0,0 +1 @@
+../../Task/Strip-block-comments/FutureBasic
\ No newline at end of file
diff --git a/Lang/FutureBasic/Strip-control-codes-and-extended-characters-from-a-string b/Lang/FutureBasic/Strip-control-codes-and-extended-characters-from-a-string
new file mode 120000
index 0000000000..ae3840dae2
--- /dev/null
+++ b/Lang/FutureBasic/Strip-control-codes-and-extended-characters-from-a-string
@@ -0,0 +1 @@
+../../Task/Strip-control-codes-and-extended-characters-from-a-string/FutureBasic
\ No newline at end of file
diff --git a/Lang/FutureBasic/Terminal-control-Coloured-text b/Lang/FutureBasic/Terminal-control-Coloured-text
new file mode 120000
index 0000000000..6858a62734
--- /dev/null
+++ b/Lang/FutureBasic/Terminal-control-Coloured-text
@@ -0,0 +1 @@
+../../Task/Terminal-control-Coloured-text/FutureBasic
\ No newline at end of file
diff --git a/Lang/FutureBasic/Terminal-control-Cursor-movement b/Lang/FutureBasic/Terminal-control-Cursor-movement
new file mode 120000
index 0000000000..050e1439d6
--- /dev/null
+++ b/Lang/FutureBasic/Terminal-control-Cursor-movement
@@ -0,0 +1 @@
+../../Task/Terminal-control-Cursor-movement/FutureBasic
\ No newline at end of file
diff --git a/Lang/FutureBasic/Terminal-control-Cursor-positioning b/Lang/FutureBasic/Terminal-control-Cursor-positioning
new file mode 120000
index 0000000000..22f710aaf6
--- /dev/null
+++ b/Lang/FutureBasic/Terminal-control-Cursor-positioning
@@ -0,0 +1 @@
+../../Task/Terminal-control-Cursor-positioning/FutureBasic
\ No newline at end of file
diff --git a/Lang/FutureBasic/Terminal-control-Hiding-the-cursor b/Lang/FutureBasic/Terminal-control-Hiding-the-cursor
new file mode 120000
index 0000000000..22bc1dda83
--- /dev/null
+++ b/Lang/FutureBasic/Terminal-control-Hiding-the-cursor
@@ -0,0 +1 @@
+../../Task/Terminal-control-Hiding-the-cursor/FutureBasic
\ No newline at end of file
diff --git a/Lang/FutureBasic/Terminal-control-Ringing-the-terminal-bell b/Lang/FutureBasic/Terminal-control-Ringing-the-terminal-bell
new file mode 120000
index 0000000000..6f8d6c609a
--- /dev/null
+++ b/Lang/FutureBasic/Terminal-control-Ringing-the-terminal-bell
@@ -0,0 +1 @@
+../../Task/Terminal-control-Ringing-the-terminal-bell/FutureBasic
\ No newline at end of file
diff --git a/Lang/FutureBasic/Terminal-control-Unicode-output b/Lang/FutureBasic/Terminal-control-Unicode-output
new file mode 120000
index 0000000000..712dfa9fa9
--- /dev/null
+++ b/Lang/FutureBasic/Terminal-control-Unicode-output
@@ -0,0 +1 @@
+../../Task/Terminal-control-Unicode-output/FutureBasic
\ No newline at end of file
diff --git a/Lang/FutureBasic/Tic-tac-toe b/Lang/FutureBasic/Tic-tac-toe
new file mode 120000
index 0000000000..e0c70b24fe
--- /dev/null
+++ b/Lang/FutureBasic/Tic-tac-toe
@@ -0,0 +1 @@
+../../Task/Tic-tac-toe/FutureBasic
\ No newline at end of file
diff --git a/Lang/FutureBasic/Use-another-language-to-call-a-function b/Lang/FutureBasic/Use-another-language-to-call-a-function
new file mode 120000
index 0000000000..704ff5c0c8
--- /dev/null
+++ b/Lang/FutureBasic/Use-another-language-to-call-a-function
@@ -0,0 +1 @@
+../../Task/Use-another-language-to-call-a-function/FutureBasic
\ No newline at end of file
diff --git a/Lang/FutureBasic/Validate-International-Securities-Identification-Number b/Lang/FutureBasic/Validate-International-Securities-Identification-Number
new file mode 120000
index 0000000000..81f74f067a
--- /dev/null
+++ b/Lang/FutureBasic/Validate-International-Securities-Identification-Number
@@ -0,0 +1 @@
+../../Task/Validate-International-Securities-Identification-Number/FutureBasic
\ No newline at end of file
diff --git a/Lang/FutureBasic/Yahoo-search-interface b/Lang/FutureBasic/Yahoo-search-interface
new file mode 120000
index 0000000000..9f29c6ac04
--- /dev/null
+++ b/Lang/FutureBasic/Yahoo-search-interface
@@ -0,0 +1 @@
+../../Task/Yahoo-search-interface/FutureBasic
\ No newline at end of file
diff --git a/Lang/GW-BASIC/Case-sensitivity-of-identifiers b/Lang/GW-BASIC/Case-sensitivity-of-identifiers
deleted file mode 120000
index 605ddebd53..0000000000
--- a/Lang/GW-BASIC/Case-sensitivity-of-identifiers
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Case-sensitivity-of-identifiers/GW-BASIC
\ No newline at end of file
diff --git a/Lang/GW-BASIC/Leonardo-numbers b/Lang/GW-BASIC/Leonardo-numbers
new file mode 120000
index 0000000000..f7945f7063
--- /dev/null
+++ b/Lang/GW-BASIC/Leonardo-numbers
@@ -0,0 +1 @@
+../../Task/Leonardo-numbers/GW-BASIC
\ No newline at end of file
diff --git a/Lang/GW-BASIC/Luhn-test-of-credit-card-numbers b/Lang/GW-BASIC/Luhn-test-of-credit-card-numbers
new file mode 120000
index 0000000000..3e46368b55
--- /dev/null
+++ b/Lang/GW-BASIC/Luhn-test-of-credit-card-numbers
@@ -0,0 +1 @@
+../../Task/Luhn-test-of-credit-card-numbers/GW-BASIC
\ No newline at end of file
diff --git a/Lang/GW-BASIC/Nth-root b/Lang/GW-BASIC/Nth-root
new file mode 120000
index 0000000000..44da5f255f
--- /dev/null
+++ b/Lang/GW-BASIC/Nth-root
@@ -0,0 +1 @@
+../../Task/Nth-root/GW-BASIC
\ No newline at end of file
diff --git a/Lang/Gambas/Generate-Chess960-starting-position b/Lang/Gambas/Generate-Chess960-starting-position
new file mode 120000
index 0000000000..3ee17430bf
--- /dev/null
+++ b/Lang/Gambas/Generate-Chess960-starting-position
@@ -0,0 +1 @@
+../../Task/Generate-Chess960-starting-position/Gambas
\ No newline at end of file
diff --git a/Lang/Go/Bifid-cipher b/Lang/Go/Bifid-cipher
new file mode 120000
index 0000000000..329ffb397d
--- /dev/null
+++ b/Lang/Go/Bifid-cipher
@@ -0,0 +1 @@
+../../Task/Bifid-cipher/Go
\ No newline at end of file
diff --git a/Lang/Go/Terminal-control-Unicode-output b/Lang/Go/Terminal-control-Unicode-output
deleted file mode 120000
index 7532989408..0000000000
--- a/Lang/Go/Terminal-control-Unicode-output
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Terminal-control-Unicode-output/Go
\ No newline at end of file
diff --git a/Lang/Golfscript/00-LANG.txt b/Lang/Golfscript/00-LANG.txt
index 67be1df4fd..ce1ed4276d 100644
--- a/Lang/Golfscript/00-LANG.txt
+++ b/Lang/Golfscript/00-LANG.txt
@@ -1,5 +1,10 @@
{{language|GolfScript
|site=http://www.golfscript.com/golfscript/index.html
}}
+{{try|Golfscript|[https://tio.run/#golfscript Try Golfscript on tio.run].}}
{{language programming paradigm|Concatenative}}
-GolfScript is a stack oriented esoteric programming language aimed at solving problems (holes) in as few keystrokes as possible. It also aims to be simple and easy to write.
\ No newline at end of file
+GolfScript is a stack oriented esoteric programming language aimed at solving problems (holes) in as few keystrokes as possible. It also aims to be simple and easy to write.
+
+== External links ==
+* [https://golfscript.com/golfscript/ Official website]
+* [https://codegolf.stackexchange.com/questions/5264/tips-for-golfing-in-golfscript Tips for golfing in Golfscript]
\ No newline at end of file
diff --git a/Lang/Guile/2048 b/Lang/Guile/2048
new file mode 120000
index 0000000000..69532585e1
--- /dev/null
+++ b/Lang/Guile/2048
@@ -0,0 +1 @@
+../../Task/2048/Guile
\ No newline at end of file
diff --git a/Lang/Guile/A+B b/Lang/Guile/A+B
new file mode 120000
index 0000000000..ea7ff34909
--- /dev/null
+++ b/Lang/Guile/A+B
@@ -0,0 +1 @@
+../../Task/A+B/Guile
\ No newline at end of file
diff --git a/Lang/Guile/MD5-Implementation b/Lang/Guile/MD5-Implementation
new file mode 120000
index 0000000000..c467572ebf
--- /dev/null
+++ b/Lang/Guile/MD5-Implementation
@@ -0,0 +1 @@
+../../Task/MD5-Implementation/Guile
\ No newline at end of file
diff --git a/Lang/Guish/00-LANG.txt b/Lang/Guish/00-LANG.txt
index 593da31c91..e15298f7c3 100644
--- a/Lang/Guish/00-LANG.txt
+++ b/Lang/Guish/00-LANG.txt
@@ -1016,7 +1016,7 @@ Any element that's not a page has a particular text alignment that can be change
-Francesco Palumbo <phranz@subfc.net>
+Francesco Palumbo
= THANKS =
diff --git a/Lang/Haskell/Bifid-cipher b/Lang/Haskell/Bifid-cipher
new file mode 120000
index 0000000000..e9402d0afc
--- /dev/null
+++ b/Lang/Haskell/Bifid-cipher
@@ -0,0 +1 @@
+../../Task/Bifid-cipher/Haskell
\ No newline at end of file
diff --git a/Lang/Idris/Palindrome-detection b/Lang/Idris/Palindrome-detection
new file mode 120000
index 0000000000..58af724843
--- /dev/null
+++ b/Lang/Idris/Palindrome-detection
@@ -0,0 +1 @@
+../../Task/Palindrome-detection/Idris
\ No newline at end of file
diff --git a/Lang/J/00-LANG.txt b/Lang/J/00-LANG.txt
index c2cd3a263c..5ca185b4f1 100644
--- a/Lang/J/00-LANG.txt
+++ b/Lang/J/00-LANG.txt
@@ -117,7 +117,7 @@ Discussion of the goals of the J community on RC and general guidelines for pres
*[[User:Lambertdw|David Lambert]]:[[Special:Contributions/Lambertdw|contributions]]
*[[User:JimTheriot|JimTheriot]]: [[Special:Contributions/JimTheriot|contributions]]
*[[User:DevonMcC|Devon McCormick]]: [[Special:Contributions/DevonMcC|contributions]]
-*[[User:Cchando|Cameron Chandoke]]: [[Special:Contributions/Cchando|contributions]]
+*[[User:Cchando|Cameron Chandoke]]: [[Special:Contributions/Cchando|contributions]], [[j:User:Cameron_Chandoke|J wiki]]
== Try me ==
diff --git a/Lang/Java/00-LANG.txt b/Lang/Java/00-LANG.txt
index 72a980a538..9df12a7429 100644
--- a/Lang/Java/00-LANG.txt
+++ b/Lang/Java/00-LANG.txt
@@ -41,4 +41,4 @@ Useful Java links:
* [http://openjdk.java.net OpenJDK]
==Todo==
-[[Reports:Tasks_not_implemented_in_Java]]
\ No newline at end of file
+[https://rosettacode.org/wiki/Tasks_not_implemented_in_Java Tasks not implemented in Java]
\ No newline at end of file
diff --git a/Lang/Java/Sylvesters-sequence b/Lang/Java/Sylvesters-sequence
new file mode 120000
index 0000000000..6dfb05d095
--- /dev/null
+++ b/Lang/Java/Sylvesters-sequence
@@ -0,0 +1 @@
+../../Task/Sylvesters-sequence/Java
\ No newline at end of file
diff --git a/Lang/JavaScript/Horizontal-sundial-calculations b/Lang/JavaScript/Horizontal-sundial-calculations
new file mode 120000
index 0000000000..854f95761b
--- /dev/null
+++ b/Lang/JavaScript/Horizontal-sundial-calculations
@@ -0,0 +1 @@
+../../Task/Horizontal-sundial-calculations/JavaScript
\ No newline at end of file
diff --git a/Lang/JavaScript/ISBN13-check-digit b/Lang/JavaScript/ISBN13-check-digit
new file mode 120000
index 0000000000..a76c26065c
--- /dev/null
+++ b/Lang/JavaScript/ISBN13-check-digit
@@ -0,0 +1 @@
+../../Task/ISBN13-check-digit/JavaScript
\ No newline at end of file
diff --git a/Lang/JavaScript/Periodic-table b/Lang/JavaScript/Periodic-table
new file mode 120000
index 0000000000..3252400859
--- /dev/null
+++ b/Lang/JavaScript/Periodic-table
@@ -0,0 +1 @@
+../../Task/Periodic-table/JavaScript
\ No newline at end of file
diff --git a/Lang/Joy/Case-sensitivity-of-identifiers b/Lang/Joy/Case-sensitivity-of-identifiers
new file mode 120000
index 0000000000..e8f5c2c1db
--- /dev/null
+++ b/Lang/Joy/Case-sensitivity-of-identifiers
@@ -0,0 +1 @@
+../../Task/Case-sensitivity-of-identifiers/Joy
\ No newline at end of file
diff --git a/Lang/Joy/Read-a-file-line-by-line b/Lang/Joy/Read-a-file-line-by-line
new file mode 120000
index 0000000000..9985d0bc9c
--- /dev/null
+++ b/Lang/Joy/Read-a-file-line-by-line
@@ -0,0 +1 @@
+../../Task/Read-a-file-line-by-line/Joy
\ No newline at end of file
diff --git a/Lang/Joy/Sort-an-integer-array b/Lang/Joy/Sort-an-integer-array
new file mode 120000
index 0000000000..91921cd08e
--- /dev/null
+++ b/Lang/Joy/Sort-an-integer-array
@@ -0,0 +1 @@
+../../Task/Sort-an-integer-array/Joy
\ No newline at end of file
diff --git a/Lang/Joy/Unicode-variable-names b/Lang/Joy/Unicode-variable-names
new file mode 120000
index 0000000000..b7f93a76ef
--- /dev/null
+++ b/Lang/Joy/Unicode-variable-names
@@ -0,0 +1 @@
+../../Task/Unicode-variable-names/Joy
\ No newline at end of file
diff --git a/Lang/K/Compare-a-list-of-strings b/Lang/K/Compare-a-list-of-strings
new file mode 120000
index 0000000000..e673df5891
--- /dev/null
+++ b/Lang/K/Compare-a-list-of-strings
@@ -0,0 +1 @@
+../../Task/Compare-a-list-of-strings/K
\ No newline at end of file
diff --git a/Lang/K/Sieve-of-Eratosthenes b/Lang/K/Sieve-of-Eratosthenes
new file mode 120000
index 0000000000..c66b9a1b22
--- /dev/null
+++ b/Lang/K/Sieve-of-Eratosthenes
@@ -0,0 +1 @@
+../../Task/Sieve-of-Eratosthenes/K
\ No newline at end of file
diff --git a/Lang/K/Sum-multiples-of-3-and-5 b/Lang/K/Sum-multiples-of-3-and-5
new file mode 120000
index 0000000000..625ba55b5f
--- /dev/null
+++ b/Lang/K/Sum-multiples-of-3-and-5
@@ -0,0 +1 @@
+../../Task/Sum-multiples-of-3-and-5/K
\ No newline at end of file
diff --git a/Lang/Kotlin/Radical-of-an-integer b/Lang/Kotlin/Radical-of-an-integer
new file mode 120000
index 0000000000..e9d51e3e8d
--- /dev/null
+++ b/Lang/Kotlin/Radical-of-an-integer
@@ -0,0 +1 @@
+../../Task/Radical-of-an-integer/Kotlin
\ No newline at end of file
diff --git a/Lang/LDPL/Command-line-arguments b/Lang/LDPL/Command-line-arguments
new file mode 120000
index 0000000000..7b4b88a226
--- /dev/null
+++ b/Lang/LDPL/Command-line-arguments
@@ -0,0 +1 @@
+../../Task/Command-line-arguments/LDPL
\ No newline at end of file
diff --git a/Lang/LOLCODE/A+B b/Lang/LOLCODE/A+B
new file mode 120000
index 0000000000..d5ea45853c
--- /dev/null
+++ b/Lang/LOLCODE/A+B
@@ -0,0 +1 @@
+../../Task/A+B/LOLCODE
\ No newline at end of file
diff --git a/Lang/Langur/Arithmetic-Complex b/Lang/Langur/Arithmetic-Complex
new file mode 120000
index 0000000000..5341d853ac
--- /dev/null
+++ b/Lang/Langur/Arithmetic-Complex
@@ -0,0 +1 @@
+../../Task/Arithmetic-Complex/Langur
\ No newline at end of file
diff --git a/Lang/Langur/Program-name b/Lang/Langur/Program-name
deleted file mode 120000
index 04198cf0de..0000000000
--- a/Lang/Langur/Program-name
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Program-name/Langur
\ No newline at end of file
diff --git a/Lang/Locomotive-Basic/Animate-a-pendulum b/Lang/Locomotive-Basic/Animate-a-pendulum
new file mode 120000
index 0000000000..32a0ee5149
--- /dev/null
+++ b/Lang/Locomotive-Basic/Animate-a-pendulum
@@ -0,0 +1 @@
+../../Task/Animate-a-pendulum/Locomotive-Basic
\ No newline at end of file
diff --git a/Lang/Locomotive-Basic/Forest-fire b/Lang/Locomotive-Basic/Forest-fire
new file mode 120000
index 0000000000..44a3c54d6a
--- /dev/null
+++ b/Lang/Locomotive-Basic/Forest-fire
@@ -0,0 +1 @@
+../../Task/Forest-fire/Locomotive-Basic
\ No newline at end of file
diff --git a/Lang/Lua/Duffinian-numbers b/Lang/Lua/Duffinian-numbers
new file mode 120000
index 0000000000..3d384f7bda
--- /dev/null
+++ b/Lang/Lua/Duffinian-numbers
@@ -0,0 +1 @@
+../../Task/Duffinian-numbers/Lua
\ No newline at end of file
diff --git a/Lang/Lua/Hello-world-Line-printer b/Lang/Lua/Hello-world-Line-printer
new file mode 120000
index 0000000000..1ade14f20f
--- /dev/null
+++ b/Lang/Lua/Hello-world-Line-printer
@@ -0,0 +1 @@
+../../Task/Hello-world-Line-printer/Lua
\ No newline at end of file
diff --git a/Lang/Lua/Parsing-RPN-calculator-algorithm b/Lang/Lua/Parsing-RPN-calculator-algorithm
deleted file mode 120000
index 397c1ccfd1..0000000000
--- a/Lang/Lua/Parsing-RPN-calculator-algorithm
+++ /dev/null
@@ -1 +0,0 @@
-../../Task/Parsing-RPN-calculator-algorithm/Lua
\ No newline at end of file
diff --git a/Lang/Lua/Summarize-primes b/Lang/Lua/Summarize-primes
new file mode 120000
index 0000000000..601bc61d3c
--- /dev/null
+++ b/Lang/Lua/Summarize-primes
@@ -0,0 +1 @@
+../../Task/Summarize-primes/Lua
\ No newline at end of file
diff --git a/Lang/M2000-Interpreter/Arbitrary-precision-integers-included- b/Lang/M2000-Interpreter/Arbitrary-precision-integers-included-
new file mode 120000
index 0000000000..4f4595771b
--- /dev/null
+++ b/Lang/M2000-Interpreter/Arbitrary-precision-integers-included-
@@ -0,0 +1 @@
+../../Task/Arbitrary-precision-integers-included-/M2000-Interpreter
\ No newline at end of file
diff --git a/Lang/M2000-Interpreter/Arithmetic-Complex b/Lang/M2000-Interpreter/Arithmetic-Complex
new file mode 120000
index 0000000000..d7240f321f
--- /dev/null
+++ b/Lang/M2000-Interpreter/Arithmetic-Complex
@@ -0,0 +1 @@
+../../Task/Arithmetic-Complex/M2000-Interpreter
\ No newline at end of file
diff --git a/Lang/M2000-Interpreter/Averages-Simple-moving-average b/Lang/M2000-Interpreter/Averages-Simple-moving-average
new file mode 120000
index 0000000000..4d812f1b4c
--- /dev/null
+++ b/Lang/M2000-Interpreter/Averages-Simple-moving-average
@@ -0,0 +1 @@
+../../Task/Averages-Simple-moving-average/M2000-Interpreter
\ No newline at end of file
diff --git a/Lang/M2000-Interpreter/Bifid-cipher b/Lang/M2000-Interpreter/Bifid-cipher
new file mode 120000
index 0000000000..c97cd39b1f
--- /dev/null
+++ b/Lang/M2000-Interpreter/Bifid-cipher
@@ -0,0 +1 @@
+../../Task/Bifid-cipher/M2000-Interpreter
\ No newline at end of file
diff --git a/Lang/M2000-Interpreter/Binary-strings b/Lang/M2000-Interpreter/Binary-strings
new file mode 120000
index 0000000000..7890dd1bf5
--- /dev/null
+++ b/Lang/M2000-Interpreter/Binary-strings
@@ -0,0 +1 @@
+../../Task/Binary-strings/M2000-Interpreter
\ No newline at end of file
diff --git a/Lang/M2000-Interpreter/Bioinformatics-base-count b/Lang/M2000-Interpreter/Bioinformatics-base-count
new file mode 120000
index 0000000000..a75bd15fc5
--- /dev/null
+++ b/Lang/M2000-Interpreter/Bioinformatics-base-count
@@ -0,0 +1 @@
+../../Task/Bioinformatics-base-count/M2000-Interpreter
\ No newline at end of file
diff --git a/Lang/M2000-Interpreter/Bitmap-B-zier-curves-Quadratic b/Lang/M2000-Interpreter/Bitmap-B-zier-curves-Quadratic
new file mode 120000
index 0000000000..2471b47323
--- /dev/null
+++ b/Lang/M2000-Interpreter/Bitmap-B-zier-curves-Quadratic
@@ -0,0 +1 @@
+../../Task/Bitmap-B-zier-curves-Quadratic/M2000-Interpreter
\ No newline at end of file
diff --git a/Lang/M2000-Interpreter/Bitmap-Bresenhams-line-algorithm b/Lang/M2000-Interpreter/Bitmap-Bresenhams-line-algorithm
new file mode 120000
index 0000000000..37e0c9a050
--- /dev/null
+++ b/Lang/M2000-Interpreter/Bitmap-Bresenhams-line-algorithm
@@ -0,0 +1 @@
+../../Task/Bitmap-Bresenhams-line-algorithm/M2000-Interpreter
\ No newline at end of file
diff --git a/Lang/M2000-Interpreter/Bitwise-operations b/Lang/M2000-Interpreter/Bitwise-operations
new file mode 120000
index 0000000000..7b5956a12b
--- /dev/null
+++ b/Lang/M2000-Interpreter/Bitwise-operations
@@ -0,0 +1 @@
+../../Task/Bitwise-operations/M2000-Interpreter
\ No newline at end of file
diff --git a/Lang/M2000-Interpreter/Compound-data-type b/Lang/M2000-Interpreter/Compound-data-type
new file mode 120000
index 0000000000..661e74ca81
--- /dev/null
+++ b/Lang/M2000-Interpreter/Compound-data-type
@@ -0,0 +1 @@
+../../Task/Compound-data-type/M2000-Interpreter
\ No newline at end of file
diff --git a/Lang/M2000-Interpreter/Count-occurrences-of-a-substring b/Lang/M2000-Interpreter/Count-occurrences-of-a-substring
new file mode 120000
index 0000000000..96e93abdc4
--- /dev/null
+++ b/Lang/M2000-Interpreter/Count-occurrences-of-a-substring
@@ -0,0 +1 @@
+../../Task/Count-occurrences-of-a-substring/M2000-Interpreter
\ No newline at end of file
diff --git a/Lang/M2000-Interpreter/Deal-cards-for-FreeCell b/Lang/M2000-Interpreter/Deal-cards-for-FreeCell
new file mode 120000
index 0000000000..59b0374429
--- /dev/null
+++ b/Lang/M2000-Interpreter/Deal-cards-for-FreeCell
@@ -0,0 +1 @@
+../../Task/Deal-cards-for-FreeCell/M2000-Interpreter
\ No newline at end of file
diff --git a/Lang/M2000-Interpreter/Doomsday-rule b/Lang/M2000-Interpreter/Doomsday-rule
new file mode 120000
index 0000000000..64bda385da
--- /dev/null
+++ b/Lang/M2000-Interpreter/Doomsday-rule
@@ -0,0 +1 @@
+../../Task/Doomsday-rule/M2000-Interpreter
\ No newline at end of file
diff --git a/Lang/M2000-Interpreter/Egyptian-division b/Lang/M2000-Interpreter/Egyptian-division
new file mode 120000
index 0000000000..ed8318ad3d
--- /dev/null
+++ b/Lang/M2000-Interpreter/Egyptian-division
@@ -0,0 +1 @@
+../../Task/Egyptian-division/M2000-Interpreter
\ No newline at end of file
diff --git a/Lang/M2000-Interpreter/Eulers-identity b/Lang/M2000-Interpreter/Eulers-identity
new file mode 120000
index 0000000000..af0f40c33c
--- /dev/null
+++ b/Lang/M2000-Interpreter/Eulers-identity
@@ -0,0 +1 @@
+../../Task/Eulers-identity/M2000-Interpreter
\ No newline at end of file
diff --git a/Lang/M2000-Interpreter/Execute-Computer-Zero b/Lang/M2000-Interpreter/Execute-Computer-Zero
new file mode 120000
index 0000000000..fecab5c3ec
--- /dev/null
+++ b/Lang/M2000-Interpreter/Execute-Computer-Zero
@@ -0,0 +1 @@
+../../Task/Execute-Computer-Zero/M2000-Interpreter
\ No newline at end of file
diff --git a/Lang/M2000-Interpreter/Fast-Fourier-transform b/Lang/M2000-Interpreter/Fast-Fourier-transform
new file mode 120000
index 0000000000..e70d70854c
--- /dev/null
+++ b/Lang/M2000-Interpreter/Fast-Fourier-transform
@@ -0,0 +1 @@
+../../Task/Fast-Fourier-transform/M2000-Interpreter
\ No newline at end of file
diff --git a/Lang/M2000-Interpreter/Four-is-magic b/Lang/M2000-Interpreter/Four-is-magic
new file mode 120000
index 0000000000..3bd19ce379
--- /dev/null
+++ b/Lang/M2000-Interpreter/Four-is-magic
@@ -0,0 +1 @@
+../../Task/Four-is-magic/M2000-Interpreter
\ No newline at end of file
diff --git a/Lang/M2000-Interpreter/ISBN13-check-digit b/Lang/M2000-Interpreter/ISBN13-check-digit
new file mode 120000
index 0000000000..b320adf2bf
--- /dev/null
+++ b/Lang/M2000-Interpreter/ISBN13-check-digit
@@ -0,0 +1 @@
+../../Task/ISBN13-check-digit/M2000-Interpreter
\ No newline at end of file
diff --git a/Lang/M2000-Interpreter/Leonardo-numbers b/Lang/M2000-Interpreter/Leonardo-numbers
new file mode 120000
index 0000000000..4f37c1babb
--- /dev/null
+++ b/Lang/M2000-Interpreter/Leonardo-numbers
@@ -0,0 +1 @@
+../../Task/Leonardo-numbers/M2000-Interpreter
\ No newline at end of file
diff --git a/Lang/M2000-Interpreter/Long-multiplication b/Lang/M2000-Interpreter/Long-multiplication
new file mode 120000
index 0000000000..ba1dc9bc62
--- /dev/null
+++ b/Lang/M2000-Interpreter/Long-multiplication
@@ -0,0 +1 @@
+../../Task/Long-multiplication/M2000-Interpreter
\ No newline at end of file
diff --git a/Lang/M2000-Interpreter/Mastermind b/Lang/M2000-Interpreter/Mastermind
new file mode 120000
index 0000000000..3cfbb80935
--- /dev/null
+++ b/Lang/M2000-Interpreter/Mastermind
@@ -0,0 +1 @@
+../../Task/Mastermind/M2000-Interpreter
\ No newline at end of file
diff --git a/Lang/M2000-Interpreter/Matrix-digital-rain b/Lang/M2000-Interpreter/Matrix-digital-rain
new file mode 120000
index 0000000000..c3f5d509a7
--- /dev/null
+++ b/Lang/M2000-Interpreter/Matrix-digital-rain
@@ -0,0 +1 @@
+../../Task/Matrix-digital-rain/M2000-Interpreter
\ No newline at end of file
diff --git a/Lang/M2000-Interpreter/Matrix-transposition b/Lang/M2000-Interpreter/Matrix-transposition
new file mode 120000
index 0000000000..5ea61d7980
--- /dev/null
+++ b/Lang/M2000-Interpreter/Matrix-transposition
@@ -0,0 +1 @@
+../../Task/Matrix-transposition/M2000-Interpreter
\ No newline at end of file
diff --git a/Lang/M2000-Interpreter/Miller-Rabin-primality-test b/Lang/M2000-Interpreter/Miller-Rabin-primality-test
new file mode 120000
index 0000000000..70c84948c0
--- /dev/null
+++ b/Lang/M2000-Interpreter/Miller-Rabin-primality-test
@@ -0,0 +1 @@
+../../Task/Miller-Rabin-primality-test/M2000-Interpreter
\ No newline at end of file
diff --git a/Lang/M2000-Interpreter/Modified-random-distribution b/Lang/M2000-Interpreter/Modified-random-distribution
new file mode 120000
index 0000000000..bbbb129f02
--- /dev/null
+++ b/Lang/M2000-Interpreter/Modified-random-distribution
@@ -0,0 +1 @@
+../../Task/Modified-random-distribution/M2000-Interpreter
\ No newline at end of file
diff --git a/Lang/M2000-Interpreter/Modular-exponentiation b/Lang/M2000-Interpreter/Modular-exponentiation
new file mode 120000
index 0000000000..99e9549d1a
--- /dev/null
+++ b/Lang/M2000-Interpreter/Modular-exponentiation
@@ -0,0 +1 @@
+../../Task/Modular-exponentiation/M2000-Interpreter
\ No newline at end of file
diff --git a/Lang/M2000-Interpreter/Morse-code b/Lang/M2000-Interpreter/Morse-code
new file mode 120000
index 0000000000..77ce05e92e
--- /dev/null
+++ b/Lang/M2000-Interpreter/Morse-code
@@ -0,0 +1 @@
+../../Task/Morse-code/M2000-Interpreter
\ No newline at end of file
diff --git a/Lang/M2000-Interpreter/Multi-dimensional-array b/Lang/M2000-Interpreter/Multi-dimensional-array
new file mode 120000
index 0000000000..24c2948fdf
--- /dev/null
+++ b/Lang/M2000-Interpreter/Multi-dimensional-array
@@ -0,0 +1 @@
+../../Task/Multi-dimensional-array/M2000-Interpreter
\ No newline at end of file
diff --git a/Lang/M2000-Interpreter/Multiple-regression b/Lang/M2000-Interpreter/Multiple-regression
new file mode 120000
index 0000000000..f645ea689c
--- /dev/null
+++ b/Lang/M2000-Interpreter/Multiple-regression
@@ -0,0 +1 @@
+../../Task/Multiple-regression/M2000-Interpreter
\ No newline at end of file
diff --git a/Lang/M2000-Interpreter/Number-names b/Lang/M2000-Interpreter/Number-names
new file mode 120000
index 0000000000..acf20af45b
--- /dev/null
+++ b/Lang/M2000-Interpreter/Number-names
@@ -0,0 +1 @@
+../../Task/Number-names/M2000-Interpreter
\ No newline at end of file
diff --git a/Lang/M2000-Interpreter/Ordered-words b/Lang/M2000-Interpreter/Ordered-words
new file mode 120000
index 0000000000..ccf0ec6f16
--- /dev/null
+++ b/Lang/M2000-Interpreter/Ordered-words
@@ -0,0 +1 @@
+../../Task/Ordered-words/M2000-Interpreter
\ No newline at end of file
diff --git a/Lang/M2000-Interpreter/Periodic-table b/Lang/M2000-Interpreter/Periodic-table
new file mode 120000
index 0000000000..0e286fad08
--- /dev/null
+++ b/Lang/M2000-Interpreter/Periodic-table
@@ -0,0 +1 @@
+../../Task/Periodic-table/M2000-Interpreter
\ No newline at end of file
diff --git a/Lang/M2000-Interpreter/Polyspiral b/Lang/M2000-Interpreter/Polyspiral
new file mode 120000
index 0000000000..f2eb619d45
--- /dev/null
+++ b/Lang/M2000-Interpreter/Polyspiral
@@ -0,0 +1 @@
+../../Task/Polyspiral/M2000-Interpreter
\ No newline at end of file
diff --git a/Lang/M2000-Interpreter/Pseudo-random-numbers-Middle-square-method b/Lang/M2000-Interpreter/Pseudo-random-numbers-Middle-square-method
new file mode 120000
index 0000000000..71371c48fd
--- /dev/null
+++ b/Lang/M2000-Interpreter/Pseudo-random-numbers-Middle-square-method
@@ -0,0 +1 @@
+../../Task/Pseudo-random-numbers-Middle-square-method/M2000-Interpreter
\ No newline at end of file
diff --git a/Lang/M2000-Interpreter/Pseudo-random-numbers-Xorshift-star b/Lang/M2000-Interpreter/Pseudo-random-numbers-Xorshift-star
new file mode 120000
index 0000000000..a60ebed0a5
--- /dev/null
+++ b/Lang/M2000-Interpreter/Pseudo-random-numbers-Xorshift-star
@@ -0,0 +1 @@
+../../Task/Pseudo-random-numbers-Xorshift-star/M2000-Interpreter
\ No newline at end of file
diff --git a/Lang/M2000-Interpreter/Read-a-specific-line-from-a-file b/Lang/M2000-Interpreter/Read-a-specific-line-from-a-file
new file mode 120000
index 0000000000..12c1b22a47
--- /dev/null
+++ b/Lang/M2000-Interpreter/Read-a-specific-line-from-a-file
@@ -0,0 +1 @@
+../../Task/Read-a-specific-line-from-a-file/M2000-Interpreter
\ No newline at end of file
diff --git a/Lang/M2000-Interpreter/Roots-of-a-quadratic-function b/Lang/M2000-Interpreter/Roots-of-a-quadratic-function
new file mode 120000
index 0000000000..0f141b08fb
--- /dev/null
+++ b/Lang/M2000-Interpreter/Roots-of-a-quadratic-function
@@ -0,0 +1 @@
+../../Task/Roots-of-a-quadratic-function/M2000-Interpreter
\ No newline at end of file
diff --git a/Lang/M2000-Interpreter/Sort-an-integer-array b/Lang/M2000-Interpreter/Sort-an-integer-array
new file mode 120000
index 0000000000..f409389d27
--- /dev/null
+++ b/Lang/M2000-Interpreter/Sort-an-integer-array
@@ -0,0 +1 @@
+../../Task/Sort-an-integer-array/M2000-Interpreter
\ No newline at end of file
diff --git a/Lang/M2000-Interpreter/Sort-an-outline-at-every-level b/Lang/M2000-Interpreter/Sort-an-outline-at-every-level
new file mode 120000
index 0000000000..b5c1e68e5d
--- /dev/null
+++ b/Lang/M2000-Interpreter/Sort-an-outline-at-every-level
@@ -0,0 +1 @@
+../../Task/Sort-an-outline-at-every-level/M2000-Interpreter
\ No newline at end of file
diff --git a/Lang/M2000-Interpreter/Taxicab-numbers b/Lang/M2000-Interpreter/Taxicab-numbers
new file mode 120000
index 0000000000..6c7f58f7d6
--- /dev/null
+++ b/Lang/M2000-Interpreter/Taxicab-numbers
@@ -0,0 +1 @@
+../../Task/Taxicab-numbers/M2000-Interpreter
\ No newline at end of file
diff --git a/Lang/M2000-Interpreter/Temperature-conversion b/Lang/M2000-Interpreter/Temperature-conversion
new file mode 120000
index 0000000000..75d9db05ed
--- /dev/null
+++ b/Lang/M2000-Interpreter/Temperature-conversion
@@ -0,0 +1 @@
+../../Task/Temperature-conversion/M2000-Interpreter
\ No newline at end of file
diff --git a/Lang/M2000-Interpreter/Terminal-control-Hiding-the-cursor b/Lang/M2000-Interpreter/Terminal-control-Hiding-the-cursor
new file mode 120000
index 0000000000..7d9e8bacf5
--- /dev/null
+++ b/Lang/M2000-Interpreter/Terminal-control-Hiding-the-cursor
@@ -0,0 +1 @@
+../../Task/Terminal-control-Hiding-the-cursor/M2000-Interpreter
\ No newline at end of file
diff --git a/Lang/M2000-Interpreter/Tree-datastructures b/Lang/M2000-Interpreter/Tree-datastructures
new file mode 120000
index 0000000000..1fa6a47d52
--- /dev/null
+++ b/Lang/M2000-Interpreter/Tree-datastructures
@@ -0,0 +1 @@
+../../Task/Tree-datastructures/M2000-Interpreter
\ No newline at end of file
diff --git a/Lang/M2000-Interpreter/Truth-table b/Lang/M2000-Interpreter/Truth-table
new file mode 120000
index 0000000000..b77fe8354b
--- /dev/null
+++ b/Lang/M2000-Interpreter/Truth-table
@@ -0,0 +1 @@
+../../Task/Truth-table/M2000-Interpreter
\ No newline at end of file
diff --git a/Lang/M2000-Interpreter/Ultra-useful-primes b/Lang/M2000-Interpreter/Ultra-useful-primes
new file mode 120000
index 0000000000..5330980a0e
--- /dev/null
+++ b/Lang/M2000-Interpreter/Ultra-useful-primes
@@ -0,0 +1 @@
+../../Task/Ultra-useful-primes/M2000-Interpreter
\ No newline at end of file
diff --git a/Lang/M2000-Interpreter/Video-display-modes b/Lang/M2000-Interpreter/Video-display-modes
new file mode 120000
index 0000000000..39ee17dc2d
--- /dev/null
+++ b/Lang/M2000-Interpreter/Video-display-modes
@@ -0,0 +1 @@
+../../Task/Video-display-modes/M2000-Interpreter
\ No newline at end of file
diff --git a/Lang/M2000-Interpreter/Window-management b/Lang/M2000-Interpreter/Window-management
new file mode 120000
index 0000000000..bb8ac9e26a
--- /dev/null
+++ b/Lang/M2000-Interpreter/Window-management
@@ -0,0 +1 @@
+../../Task/Window-management/M2000-Interpreter
\ No newline at end of file
diff --git a/Lang/M2000-Interpreter/Write-language-name-in-3D-ASCII b/Lang/M2000-Interpreter/Write-language-name-in-3D-ASCII
new file mode 120000
index 0000000000..3ec6cbeb80
--- /dev/null
+++ b/Lang/M2000-Interpreter/Write-language-name-in-3D-ASCII
@@ -0,0 +1 @@
+../../Task/Write-language-name-in-3D-ASCII/M2000-Interpreter
\ No newline at end of file
diff --git a/Lang/MAD/Arithmetic-derivative b/Lang/MAD/Arithmetic-derivative
new file mode 120000
index 0000000000..e7c006ae6c
--- /dev/null
+++ b/Lang/MAD/Arithmetic-derivative
@@ -0,0 +1 @@
+../../Task/Arithmetic-derivative/MAD
\ No newline at end of file
diff --git a/Lang/Miranda/Align-columns b/Lang/Miranda/Align-columns
new file mode 120000
index 0000000000..ca88577a8d
--- /dev/null
+++ b/Lang/Miranda/Align-columns
@@ -0,0 +1 @@
+../../Task/Align-columns/Miranda
\ No newline at end of file
diff --git a/Lang/Miranda/Arithmetic-derivative b/Lang/Miranda/Arithmetic-derivative
new file mode 120000
index 0000000000..91683ddf96
--- /dev/null
+++ b/Lang/Miranda/Arithmetic-derivative
@@ -0,0 +1 @@
+../../Task/Arithmetic-derivative/Miranda
\ No newline at end of file
diff --git a/Lang/Miranda/Bell-numbers b/Lang/Miranda/Bell-numbers
new file mode 120000
index 0000000000..6635e596b0
--- /dev/null
+++ b/Lang/Miranda/Bell-numbers
@@ -0,0 +1 @@
+../../Task/Bell-numbers/Miranda
\ No newline at end of file
diff --git a/Lang/Miranda/Doomsday-rule b/Lang/Miranda/Doomsday-rule
new file mode 120000
index 0000000000..91e25767d0
--- /dev/null
+++ b/Lang/Miranda/Doomsday-rule
@@ -0,0 +1 @@
+../../Task/Doomsday-rule/Miranda
\ No newline at end of file
diff --git a/Lang/Miranda/Isqrt-integer-square-root-of-X b/Lang/Miranda/Isqrt-integer-square-root-of-X
new file mode 120000
index 0000000000..4b479d99e5
--- /dev/null
+++ b/Lang/Miranda/Isqrt-integer-square-root-of-X
@@ -0,0 +1 @@
+../../Task/Isqrt-integer-square-root-of-X/Miranda
\ No newline at end of file
diff --git a/Lang/Miranda/Leonardo-numbers b/Lang/Miranda/Leonardo-numbers
new file mode 120000
index 0000000000..6f062a014a
--- /dev/null
+++ b/Lang/Miranda/Leonardo-numbers
@@ -0,0 +1 @@
+../../Task/Leonardo-numbers/Miranda
\ No newline at end of file
diff --git a/Lang/Miranda/Mutual-recursion b/Lang/Miranda/Mutual-recursion
new file mode 120000
index 0000000000..42af709518
--- /dev/null
+++ b/Lang/Miranda/Mutual-recursion
@@ -0,0 +1 @@
+../../Task/Mutual-recursion/Miranda
\ No newline at end of file
diff --git a/Lang/Modula-2/Luhn-test-of-credit-card-numbers b/Lang/Modula-2/Luhn-test-of-credit-card-numbers
new file mode 120000
index 0000000000..7ff802d85c
--- /dev/null
+++ b/Lang/Modula-2/Luhn-test-of-credit-card-numbers
@@ -0,0 +1 @@
+../../Task/Luhn-test-of-credit-card-numbers/Modula-2
\ No newline at end of file
diff --git a/Lang/Modula-2/Nth-root b/Lang/Modula-2/Nth-root
new file mode 120000
index 0000000000..0efaa69472
--- /dev/null
+++ b/Lang/Modula-2/Nth-root
@@ -0,0 +1 @@
+../../Task/Nth-root/Modula-2
\ No newline at end of file
diff --git a/Lang/Modula-2/Periodic-table b/Lang/Modula-2/Periodic-table
new file mode 120000
index 0000000000..20953bda9a
--- /dev/null
+++ b/Lang/Modula-2/Periodic-table
@@ -0,0 +1 @@
+../../Task/Periodic-table/Modula-2
\ No newline at end of file
diff --git a/Lang/Modula-2/Temperature-conversion b/Lang/Modula-2/Temperature-conversion
new file mode 120000
index 0000000000..fa236503d3
--- /dev/null
+++ b/Lang/Modula-2/Temperature-conversion
@@ -0,0 +1 @@
+../../Task/Temperature-conversion/Modula-2
\ No newline at end of file
diff --git a/Lang/Modula-2/Tic-tac-toe b/Lang/Modula-2/Tic-tac-toe
new file mode 120000
index 0000000000..21b0370c7a
--- /dev/null
+++ b/Lang/Modula-2/Tic-tac-toe
@@ -0,0 +1 @@
+../../Task/Tic-tac-toe/Modula-2
\ No newline at end of file
diff --git a/Lang/Nascom-BASIC/Dragon-curve b/Lang/Nascom-BASIC/Dragon-curve
new file mode 120000
index 0000000000..36b4172957
--- /dev/null
+++ b/Lang/Nascom-BASIC/Dragon-curve
@@ -0,0 +1 @@
+../../Task/Dragon-curve/Nascom-BASIC
\ No newline at end of file
diff --git a/Lang/Nascom-BASIC/Luhn-test-of-credit-card-numbers b/Lang/Nascom-BASIC/Luhn-test-of-credit-card-numbers
new file mode 120000
index 0000000000..1d7e8b0698
--- /dev/null
+++ b/Lang/Nascom-BASIC/Luhn-test-of-credit-card-numbers
@@ -0,0 +1 @@
+../../Task/Luhn-test-of-credit-card-numbers/Nascom-BASIC
\ No newline at end of file
diff --git a/Lang/NetRexx/00-LANG.txt b/Lang/NetRexx/00-LANG.txt
index f110c9bdb8..3f624ad431 100644
--- a/Lang/NetRexx/00-LANG.txt
+++ b/Lang/NetRexx/00-LANG.txt
@@ -29,7 +29,7 @@ as languages such as Java, while preserving the low threshold to learning and th
On the 8th of June 2011, IBM transferred ownership of the reference implementation of NetRexx to The Rexx Language Association (RexxLA) for administration under the [http://site.icu-project.org ICU - International Components for Unicode] open source license.
-On September 12th 2022, NetRexx 4.04 was released
+On March 3rd, 2024, NetRexx 4.06-GA was released.
==== Useful Links ====
* [http://www.netrexx.org The NetRexx Programming Language - www.netrexx.org]
diff --git a/Lang/Object-Pascal/Sorting-algorithms-Shell-sort b/Lang/Object-Pascal/Sorting-algorithms-Shell-sort
new file mode 120000
index 0000000000..6ae9067d88
--- /dev/null
+++ b/Lang/Object-Pascal/Sorting-algorithms-Shell-sort
@@ -0,0 +1 @@
+../../Task/Sorting-algorithms-Shell-sort/Object-Pascal
\ No newline at end of file
diff --git a/Lang/Octave/Peripheral-drift-illusion b/Lang/Octave/Peripheral-drift-illusion
new file mode 120000
index 0000000000..9bda77fd28
--- /dev/null
+++ b/Lang/Octave/Peripheral-drift-illusion
@@ -0,0 +1 @@
+../../Task/Peripheral-drift-illusion/Octave
\ No newline at end of file
diff --git a/Lang/Odin/Sieve-of-Eratosthenes b/Lang/Odin/Sieve-of-Eratosthenes
new file mode 120000
index 0000000000..265789a7db
--- /dev/null
+++ b/Lang/Odin/Sieve-of-Eratosthenes
@@ -0,0 +1 @@
+../../Task/Sieve-of-Eratosthenes/Odin
\ No newline at end of file
diff --git a/Lang/OoRexx/Nth-root b/Lang/OoRexx/Nth-root
new file mode 120000
index 0000000000..05543d43a8
--- /dev/null
+++ b/Lang/OoRexx/Nth-root
@@ -0,0 +1 @@
+../../Task/Nth-root/OoRexx
\ No newline at end of file
diff --git a/Lang/OoRexx/Sorting-algorithms-Merge-sort b/Lang/OoRexx/Sorting-algorithms-Merge-sort
new file mode 120000
index 0000000000..ae6f4594d4
--- /dev/null
+++ b/Lang/OoRexx/Sorting-algorithms-Merge-sort
@@ -0,0 +1 @@
+../../Task/Sorting-algorithms-Merge-sort/OoRexx
\ No newline at end of file
diff --git a/Lang/OxygenBasic/Blum-integer b/Lang/OxygenBasic/Blum-integer
new file mode 120000
index 0000000000..343ecf7af1
--- /dev/null
+++ b/Lang/OxygenBasic/Blum-integer
@@ -0,0 +1 @@
+../../Task/Blum-integer/OxygenBasic
\ No newline at end of file
diff --git a/Lang/OxygenBasic/Eban-numbers b/Lang/OxygenBasic/Eban-numbers
new file mode 120000
index 0000000000..4b362db2df
--- /dev/null
+++ b/Lang/OxygenBasic/Eban-numbers
@@ -0,0 +1 @@
+../../Task/Eban-numbers/OxygenBasic
\ No newline at end of file
diff --git a/Lang/PARI-GP/Achilles-numbers b/Lang/PARI-GP/Achilles-numbers
new file mode 120000
index 0000000000..73f3f645b5
--- /dev/null
+++ b/Lang/PARI-GP/Achilles-numbers
@@ -0,0 +1 @@
+../../Task/Achilles-numbers/PARI-GP
\ No newline at end of file
diff --git a/Lang/PARI-GP/Almkvist-Giullera-formula-for-pi b/Lang/PARI-GP/Almkvist-Giullera-formula-for-pi
new file mode 120000
index 0000000000..53d950c5f0
--- /dev/null
+++ b/Lang/PARI-GP/Almkvist-Giullera-formula-for-pi
@@ -0,0 +1 @@
+../../Task/Almkvist-Giullera-formula-for-pi/PARI-GP
\ No newline at end of file
diff --git a/Lang/PARI-GP/Bell-numbers b/Lang/PARI-GP/Bell-numbers
new file mode 120000
index 0000000000..c0de777713
--- /dev/null
+++ b/Lang/PARI-GP/Bell-numbers
@@ -0,0 +1 @@
+../../Task/Bell-numbers/PARI-GP
\ No newline at end of file
diff --git a/Lang/PHP/Angle-difference-between-two-bearings b/Lang/PHP/Angle-difference-between-two-bearings
new file mode 120000
index 0000000000..357602b50f
--- /dev/null
+++ b/Lang/PHP/Angle-difference-between-two-bearings
@@ -0,0 +1 @@
+../../Task/Angle-difference-between-two-bearings/PHP
\ No newline at end of file
diff --git a/Lang/PHP/Horizontal-sundial-calculations b/Lang/PHP/Horizontal-sundial-calculations
new file mode 120000
index 0000000000..a385f37a68
--- /dev/null
+++ b/Lang/PHP/Horizontal-sundial-calculations
@@ -0,0 +1 @@
+../../Task/Horizontal-sundial-calculations/PHP
\ No newline at end of file
diff --git a/Lang/PHP/Leonardo-numbers b/Lang/PHP/Leonardo-numbers
new file mode 120000
index 0000000000..4b3cefd6f0
--- /dev/null
+++ b/Lang/PHP/Leonardo-numbers
@@ -0,0 +1 @@
+../../Task/Leonardo-numbers/PHP
\ No newline at end of file
diff --git a/Lang/PL-I-80/Square-free-integers b/Lang/PL-I-80/Square-free-integers
new file mode 120000
index 0000000000..6f8a00edb8
--- /dev/null
+++ b/Lang/PL-I-80/Square-free-integers
@@ -0,0 +1 @@
+../../Task/Square-free-integers/PL-I-80
\ No newline at end of file
diff --git a/Lang/PL-I/Arithmetic-derivative b/Lang/PL-I/Arithmetic-derivative
new file mode 120000
index 0000000000..37f109623d
--- /dev/null
+++ b/Lang/PL-I/Arithmetic-derivative
@@ -0,0 +1 @@
+../../Task/Arithmetic-derivative/PL-I
\ No newline at end of file
diff --git a/Lang/PL-M/Arithmetic-derivative b/Lang/PL-M/Arithmetic-derivative
new file mode 120000
index 0000000000..13f3e396fe
--- /dev/null
+++ b/Lang/PL-M/Arithmetic-derivative
@@ -0,0 +1 @@
+../../Task/Arithmetic-derivative/PL-M
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Babbage-problem b/Lang/PascalABC.NET/Babbage-problem
new file mode 120000
index 0000000000..0c9b0d20ea
--- /dev/null
+++ b/Lang/PascalABC.NET/Babbage-problem
@@ -0,0 +1 @@
+../../Task/Babbage-problem/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Catalan-numbers-Pascals-triangle b/Lang/PascalABC.NET/Catalan-numbers-Pascals-triangle
new file mode 120000
index 0000000000..47a30d7f38
--- /dev/null
+++ b/Lang/PascalABC.NET/Catalan-numbers-Pascals-triangle
@@ -0,0 +1 @@
+../../Task/Catalan-numbers-Pascals-triangle/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Dijkstras-algorithm b/Lang/PascalABC.NET/Dijkstras-algorithm
new file mode 120000
index 0000000000..d9c1782412
--- /dev/null
+++ b/Lang/PascalABC.NET/Dijkstras-algorithm
@@ -0,0 +1 @@
+../../Task/Dijkstras-algorithm/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Fast-Fourier-transform b/Lang/PascalABC.NET/Fast-Fourier-transform
new file mode 120000
index 0000000000..2ebeb31f36
--- /dev/null
+++ b/Lang/PascalABC.NET/Fast-Fourier-transform
@@ -0,0 +1 @@
+../../Task/Fast-Fourier-transform/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Gaussian-elimination b/Lang/PascalABC.NET/Gaussian-elimination
new file mode 120000
index 0000000000..263ffc6099
--- /dev/null
+++ b/Lang/PascalABC.NET/Gaussian-elimination
@@ -0,0 +1 @@
+../../Task/Gaussian-elimination/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Generate-Chess960-starting-position b/Lang/PascalABC.NET/Generate-Chess960-starting-position
new file mode 120000
index 0000000000..0f95aaeb00
--- /dev/null
+++ b/Lang/PascalABC.NET/Generate-Chess960-starting-position
@@ -0,0 +1 @@
+../../Task/Generate-Chess960-starting-position/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Goldbachs-comet b/Lang/PascalABC.NET/Goldbachs-comet
new file mode 120000
index 0000000000..01fcc2a336
--- /dev/null
+++ b/Lang/PascalABC.NET/Goldbachs-comet
@@ -0,0 +1 @@
+../../Task/Goldbachs-comet/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Haversine-formula b/Lang/PascalABC.NET/Haversine-formula
new file mode 120000
index 0000000000..505d4c95b1
--- /dev/null
+++ b/Lang/PascalABC.NET/Haversine-formula
@@ -0,0 +1 @@
+../../Task/Haversine-formula/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Heronian-triangles b/Lang/PascalABC.NET/Heronian-triangles
new file mode 120000
index 0000000000..38597384c9
--- /dev/null
+++ b/Lang/PascalABC.NET/Heronian-triangles
@@ -0,0 +1 @@
+../../Task/Heronian-triangles/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Hex-words b/Lang/PascalABC.NET/Hex-words
new file mode 120000
index 0000000000..487faee543
--- /dev/null
+++ b/Lang/PascalABC.NET/Hex-words
@@ -0,0 +1 @@
+../../Task/Hex-words/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Hickerson-series-of-almost-integers b/Lang/PascalABC.NET/Hickerson-series-of-almost-integers
new file mode 120000
index 0000000000..8789a0cbe0
--- /dev/null
+++ b/Lang/PascalABC.NET/Hickerson-series-of-almost-integers
@@ -0,0 +1 @@
+../../Task/Hickerson-series-of-almost-integers/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Hofstadter-Conway-$10-000-sequence b/Lang/PascalABC.NET/Hofstadter-Conway-$10-000-sequence
new file mode 120000
index 0000000000..6f07522b20
--- /dev/null
+++ b/Lang/PascalABC.NET/Hofstadter-Conway-$10-000-sequence
@@ -0,0 +1 @@
+../../Task/Hofstadter-Conway-$10-000-sequence/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Hofstadter-Figure-Figure-sequences b/Lang/PascalABC.NET/Hofstadter-Figure-Figure-sequences
new file mode 120000
index 0000000000..658c56f7ad
--- /dev/null
+++ b/Lang/PascalABC.NET/Hofstadter-Figure-Figure-sequences
@@ -0,0 +1 @@
+../../Task/Hofstadter-Figure-Figure-sequences/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Hofstadter-Q-sequence b/Lang/PascalABC.NET/Hofstadter-Q-sequence
new file mode 120000
index 0000000000..454e935a80
--- /dev/null
+++ b/Lang/PascalABC.NET/Hofstadter-Q-sequence
@@ -0,0 +1 @@
+../../Task/Hofstadter-Q-sequence/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Horizontal-sundial-calculations b/Lang/PascalABC.NET/Horizontal-sundial-calculations
new file mode 120000
index 0000000000..6ab4227b2a
--- /dev/null
+++ b/Lang/PascalABC.NET/Horizontal-sundial-calculations
@@ -0,0 +1 @@
+../../Task/Horizontal-sundial-calculations/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Humble-numbers b/Lang/PascalABC.NET/Humble-numbers
new file mode 120000
index 0000000000..ee2cb9aa95
--- /dev/null
+++ b/Lang/PascalABC.NET/Humble-numbers
@@ -0,0 +1 @@
+../../Task/Humble-numbers/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/IBAN b/Lang/PascalABC.NET/IBAN
new file mode 120000
index 0000000000..2a1610e29a
--- /dev/null
+++ b/Lang/PascalABC.NET/IBAN
@@ -0,0 +1 @@
+../../Task/IBAN/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/ISBN13-check-digit b/Lang/PascalABC.NET/ISBN13-check-digit
new file mode 120000
index 0000000000..1cc5a9193a
--- /dev/null
+++ b/Lang/PascalABC.NET/ISBN13-check-digit
@@ -0,0 +1 @@
+../../Task/ISBN13-check-digit/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Increasing-gaps-between-consecutive-Niven-numbers b/Lang/PascalABC.NET/Increasing-gaps-between-consecutive-Niven-numbers
new file mode 120000
index 0000000000..cff91f6819
--- /dev/null
+++ b/Lang/PascalABC.NET/Increasing-gaps-between-consecutive-Niven-numbers
@@ -0,0 +1 @@
+../../Task/Increasing-gaps-between-consecutive-Niven-numbers/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Intersecting-number-wheels b/Lang/PascalABC.NET/Intersecting-number-wheels
new file mode 120000
index 0000000000..5d79870677
--- /dev/null
+++ b/Lang/PascalABC.NET/Intersecting-number-wheels
@@ -0,0 +1 @@
+../../Task/Intersecting-number-wheels/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Isograms-and-heterograms b/Lang/PascalABC.NET/Isograms-and-heterograms
new file mode 120000
index 0000000000..bf330eefcd
--- /dev/null
+++ b/Lang/PascalABC.NET/Isograms-and-heterograms
@@ -0,0 +1 @@
+../../Task/Isograms-and-heterograms/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Isqrt-integer-square-root-of-X b/Lang/PascalABC.NET/Isqrt-integer-square-root-of-X
new file mode 120000
index 0000000000..5e922bc6f6
--- /dev/null
+++ b/Lang/PascalABC.NET/Isqrt-integer-square-root-of-X
@@ -0,0 +1 @@
+../../Task/Isqrt-integer-square-root-of-X/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Iterated-digits-squaring b/Lang/PascalABC.NET/Iterated-digits-squaring
new file mode 120000
index 0000000000..d26b072d9f
--- /dev/null
+++ b/Lang/PascalABC.NET/Iterated-digits-squaring
@@ -0,0 +1 @@
+../../Task/Iterated-digits-squaring/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Jacobi-symbol b/Lang/PascalABC.NET/Jacobi-symbol
new file mode 120000
index 0000000000..beae5f110d
--- /dev/null
+++ b/Lang/PascalABC.NET/Jacobi-symbol
@@ -0,0 +1 @@
+../../Task/Jacobi-symbol/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Jacobsthal-numbers b/Lang/PascalABC.NET/Jacobsthal-numbers
new file mode 120000
index 0000000000..876df13cd2
--- /dev/null
+++ b/Lang/PascalABC.NET/Jacobsthal-numbers
@@ -0,0 +1 @@
+../../Task/Jacobsthal-numbers/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Jensens-Device b/Lang/PascalABC.NET/Jensens-Device
new file mode 120000
index 0000000000..b995733017
--- /dev/null
+++ b/Lang/PascalABC.NET/Jensens-Device
@@ -0,0 +1 @@
+../../Task/Jensens-Device/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/JortSort b/Lang/PascalABC.NET/JortSort
new file mode 120000
index 0000000000..7235c60479
--- /dev/null
+++ b/Lang/PascalABC.NET/JortSort
@@ -0,0 +1 @@
+../../Task/JortSort/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Josephus-problem b/Lang/PascalABC.NET/Josephus-problem
new file mode 120000
index 0000000000..b62f88327b
--- /dev/null
+++ b/Lang/PascalABC.NET/Josephus-problem
@@ -0,0 +1 @@
+../../Task/Josephus-problem/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Juggler-sequence b/Lang/PascalABC.NET/Juggler-sequence
new file mode 120000
index 0000000000..11d7432b3c
--- /dev/null
+++ b/Lang/PascalABC.NET/Juggler-sequence
@@ -0,0 +1 @@
+../../Task/Juggler-sequence/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Julia-set b/Lang/PascalABC.NET/Julia-set
new file mode 120000
index 0000000000..905a140bc7
--- /dev/null
+++ b/Lang/PascalABC.NET/Julia-set
@@ -0,0 +1 @@
+../../Task/Julia-set/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Kernighans-large-earthquake-problem b/Lang/PascalABC.NET/Kernighans-large-earthquake-problem
new file mode 120000
index 0000000000..bfd99d6f53
--- /dev/null
+++ b/Lang/PascalABC.NET/Kernighans-large-earthquake-problem
@@ -0,0 +1 @@
+../../Task/Kernighans-large-earthquake-problem/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Knapsack-problem-0-1 b/Lang/PascalABC.NET/Knapsack-problem-0-1
new file mode 120000
index 0000000000..2fbfd42a60
--- /dev/null
+++ b/Lang/PascalABC.NET/Knapsack-problem-0-1
@@ -0,0 +1 @@
+../../Task/Knapsack-problem-0-1/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Knuths-algorithm-S b/Lang/PascalABC.NET/Knuths-algorithm-S
new file mode 120000
index 0000000000..5898ddfb2a
--- /dev/null
+++ b/Lang/PascalABC.NET/Knuths-algorithm-S
@@ -0,0 +1 @@
+../../Task/Knuths-algorithm-S/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Knuths-power-tree b/Lang/PascalABC.NET/Knuths-power-tree
new file mode 120000
index 0000000000..985187fb94
--- /dev/null
+++ b/Lang/PascalABC.NET/Knuths-power-tree
@@ -0,0 +1 @@
+../../Task/Knuths-power-tree/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Kolakoski-sequence b/Lang/PascalABC.NET/Kolakoski-sequence
new file mode 120000
index 0000000000..141e5ac2f1
--- /dev/null
+++ b/Lang/PascalABC.NET/Kolakoski-sequence
@@ -0,0 +1 @@
+../../Task/Kolakoski-sequence/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Kosaraju b/Lang/PascalABC.NET/Kosaraju
new file mode 120000
index 0000000000..b461c7f092
--- /dev/null
+++ b/Lang/PascalABC.NET/Kosaraju
@@ -0,0 +1 @@
+../../Task/Kosaraju/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Kronecker-product b/Lang/PascalABC.NET/Kronecker-product
new file mode 120000
index 0000000000..d78d832294
--- /dev/null
+++ b/Lang/PascalABC.NET/Kronecker-product
@@ -0,0 +1 @@
+../../Task/Kronecker-product/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Kronecker-product-based-fractals b/Lang/PascalABC.NET/Kronecker-product-based-fractals
new file mode 120000
index 0000000000..47d2054ae1
--- /dev/null
+++ b/Lang/PascalABC.NET/Kronecker-product-based-fractals
@@ -0,0 +1 @@
+../../Task/Kronecker-product-based-fractals/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/LZW-compression b/Lang/PascalABC.NET/LZW-compression
new file mode 120000
index 0000000000..caca350ee1
--- /dev/null
+++ b/Lang/PascalABC.NET/LZW-compression
@@ -0,0 +1 @@
+../../Task/LZW-compression/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Lah-numbers b/Lang/PascalABC.NET/Lah-numbers
new file mode 120000
index 0000000000..6d00cf7c92
--- /dev/null
+++ b/Lang/PascalABC.NET/Lah-numbers
@@ -0,0 +1 @@
+../../Task/Lah-numbers/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Langtons-ant b/Lang/PascalABC.NET/Langtons-ant
new file mode 120000
index 0000000000..7c98b40d3c
--- /dev/null
+++ b/Lang/PascalABC.NET/Langtons-ant
@@ -0,0 +1 @@
+../../Task/Langtons-ant/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Largest-int-from-concatenated-ints b/Lang/PascalABC.NET/Largest-int-from-concatenated-ints
new file mode 120000
index 0000000000..97fdfc9525
--- /dev/null
+++ b/Lang/PascalABC.NET/Largest-int-from-concatenated-ints
@@ -0,0 +1 @@
+../../Task/Largest-int-from-concatenated-ints/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Largest-number-divisible-by-its-digits b/Lang/PascalABC.NET/Largest-number-divisible-by-its-digits
new file mode 120000
index 0000000000..40a547007f
--- /dev/null
+++ b/Lang/PascalABC.NET/Largest-number-divisible-by-its-digits
@@ -0,0 +1 @@
+../../Task/Largest-number-divisible-by-its-digits/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Largest-proper-divisor-of-n b/Lang/PascalABC.NET/Largest-proper-divisor-of-n
new file mode 120000
index 0000000000..2988b13d98
--- /dev/null
+++ b/Lang/PascalABC.NET/Largest-proper-divisor-of-n
@@ -0,0 +1 @@
+../../Task/Largest-proper-divisor-of-n/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Last-Friday-of-each-month b/Lang/PascalABC.NET/Last-Friday-of-each-month
new file mode 120000
index 0000000000..bcb04c8152
--- /dev/null
+++ b/Lang/PascalABC.NET/Last-Friday-of-each-month
@@ -0,0 +1 @@
+../../Task/Last-Friday-of-each-month/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Last-letter-first-letter b/Lang/PascalABC.NET/Last-letter-first-letter
new file mode 120000
index 0000000000..19b2a978ef
--- /dev/null
+++ b/Lang/PascalABC.NET/Last-letter-first-letter
@@ -0,0 +1 @@
+../../Task/Last-letter-first-letter/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Law-of-cosines---triples b/Lang/PascalABC.NET/Law-of-cosines---triples
new file mode 120000
index 0000000000..c3f4700866
--- /dev/null
+++ b/Lang/PascalABC.NET/Law-of-cosines---triples
@@ -0,0 +1 @@
+../../Task/Law-of-cosines---triples/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Leonardo-numbers b/Lang/PascalABC.NET/Leonardo-numbers
new file mode 120000
index 0000000000..0895bc3d59
--- /dev/null
+++ b/Lang/PascalABC.NET/Leonardo-numbers
@@ -0,0 +1 @@
+../../Task/Leonardo-numbers/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Levenshtein-distance b/Lang/PascalABC.NET/Levenshtein-distance
new file mode 120000
index 0000000000..e32fc71042
--- /dev/null
+++ b/Lang/PascalABC.NET/Levenshtein-distance
@@ -0,0 +1 @@
+../../Task/Levenshtein-distance/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Literals-Integer b/Lang/PascalABC.NET/Literals-Integer
new file mode 120000
index 0000000000..a9aac3cffe
--- /dev/null
+++ b/Lang/PascalABC.NET/Literals-Integer
@@ -0,0 +1 @@
+../../Task/Literals-Integer/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Logistic-curve-fitting-in-epidemiology b/Lang/PascalABC.NET/Logistic-curve-fitting-in-epidemiology
new file mode 120000
index 0000000000..9ae308e46e
--- /dev/null
+++ b/Lang/PascalABC.NET/Logistic-curve-fitting-in-epidemiology
@@ -0,0 +1 @@
+../../Task/Logistic-curve-fitting-in-epidemiology/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Long-literals-with-continuations b/Lang/PascalABC.NET/Long-literals-with-continuations
new file mode 120000
index 0000000000..cef817d9b6
--- /dev/null
+++ b/Lang/PascalABC.NET/Long-literals-with-continuations
@@ -0,0 +1 @@
+../../Task/Long-literals-with-continuations/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Long-multiplication b/Lang/PascalABC.NET/Long-multiplication
new file mode 120000
index 0000000000..3da90eb79b
--- /dev/null
+++ b/Lang/PascalABC.NET/Long-multiplication
@@ -0,0 +1 @@
+../../Task/Long-multiplication/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Long-primes b/Lang/PascalABC.NET/Long-primes
new file mode 120000
index 0000000000..f90c1c5b51
--- /dev/null
+++ b/Lang/PascalABC.NET/Long-primes
@@ -0,0 +1 @@
+../../Task/Long-primes/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Long-year b/Lang/PascalABC.NET/Long-year
new file mode 120000
index 0000000000..cfbd0a990c
--- /dev/null
+++ b/Lang/PascalABC.NET/Long-year
@@ -0,0 +1 @@
+../../Task/Long-year/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Longest-common-substring b/Lang/PascalABC.NET/Longest-common-substring
new file mode 120000
index 0000000000..c8e27105a8
--- /dev/null
+++ b/Lang/PascalABC.NET/Longest-common-substring
@@ -0,0 +1 @@
+../../Task/Longest-common-substring/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Longest-increasing-subsequence b/Lang/PascalABC.NET/Longest-increasing-subsequence
new file mode 120000
index 0000000000..256a8afb28
--- /dev/null
+++ b/Lang/PascalABC.NET/Longest-increasing-subsequence
@@ -0,0 +1 @@
+../../Task/Longest-increasing-subsequence/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Look-and-say-sequence b/Lang/PascalABC.NET/Look-and-say-sequence
new file mode 120000
index 0000000000..a23016f201
--- /dev/null
+++ b/Lang/PascalABC.NET/Look-and-say-sequence
@@ -0,0 +1 @@
+../../Task/Look-and-say-sequence/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Lucas-Lehmer-test b/Lang/PascalABC.NET/Lucas-Lehmer-test
new file mode 120000
index 0000000000..bec917b045
--- /dev/null
+++ b/Lang/PascalABC.NET/Lucas-Lehmer-test
@@ -0,0 +1 @@
+../../Task/Lucas-Lehmer-test/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Ludic-numbers b/Lang/PascalABC.NET/Ludic-numbers
new file mode 120000
index 0000000000..84c5abb4fd
--- /dev/null
+++ b/Lang/PascalABC.NET/Ludic-numbers
@@ -0,0 +1 @@
+../../Task/Ludic-numbers/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Luhn-test-of-credit-card-numbers b/Lang/PascalABC.NET/Luhn-test-of-credit-card-numbers
new file mode 120000
index 0000000000..00804b09b8
--- /dev/null
+++ b/Lang/PascalABC.NET/Luhn-test-of-credit-card-numbers
@@ -0,0 +1 @@
+../../Task/Luhn-test-of-credit-card-numbers/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Lychrel-numbers b/Lang/PascalABC.NET/Lychrel-numbers
new file mode 120000
index 0000000000..c6935e364e
--- /dev/null
+++ b/Lang/PascalABC.NET/Lychrel-numbers
@@ -0,0 +1 @@
+../../Task/Lychrel-numbers/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/M-bius-function b/Lang/PascalABC.NET/M-bius-function
new file mode 120000
index 0000000000..e6445ec3ed
--- /dev/null
+++ b/Lang/PascalABC.NET/M-bius-function
@@ -0,0 +1 @@
+../../Task/M-bius-function/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/MAC-vendor-lookup b/Lang/PascalABC.NET/MAC-vendor-lookup
new file mode 120000
index 0000000000..d35cdd8c9b
--- /dev/null
+++ b/Lang/PascalABC.NET/MAC-vendor-lookup
@@ -0,0 +1 @@
+../../Task/MAC-vendor-lookup/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/MD5 b/Lang/PascalABC.NET/MD5
new file mode 120000
index 0000000000..375523a297
--- /dev/null
+++ b/Lang/PascalABC.NET/MD5
@@ -0,0 +1 @@
+../../Task/MD5/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Magic-constant b/Lang/PascalABC.NET/Magic-constant
new file mode 120000
index 0000000000..822ebb4fb2
--- /dev/null
+++ b/Lang/PascalABC.NET/Magic-constant
@@ -0,0 +1 @@
+../../Task/Magic-constant/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Magic-squares-of-doubly-even-order b/Lang/PascalABC.NET/Magic-squares-of-doubly-even-order
new file mode 120000
index 0000000000..b8c93bc64a
--- /dev/null
+++ b/Lang/PascalABC.NET/Magic-squares-of-doubly-even-order
@@ -0,0 +1 @@
+../../Task/Magic-squares-of-doubly-even-order/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Magnanimous-numbers b/Lang/PascalABC.NET/Magnanimous-numbers
new file mode 120000
index 0000000000..0a895d4414
--- /dev/null
+++ b/Lang/PascalABC.NET/Magnanimous-numbers
@@ -0,0 +1 @@
+../../Task/Magnanimous-numbers/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Map-range b/Lang/PascalABC.NET/Map-range
new file mode 120000
index 0000000000..2c5d9ac526
--- /dev/null
+++ b/Lang/PascalABC.NET/Map-range
@@ -0,0 +1 @@
+../../Task/Map-range/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Maximum-triangle-path-sum b/Lang/PascalABC.NET/Maximum-triangle-path-sum
new file mode 120000
index 0000000000..d476233920
--- /dev/null
+++ b/Lang/PascalABC.NET/Maximum-triangle-path-sum
@@ -0,0 +1 @@
+../../Task/Maximum-triangle-path-sum/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Maze-generation b/Lang/PascalABC.NET/Maze-generation
new file mode 120000
index 0000000000..147e928cb8
--- /dev/null
+++ b/Lang/PascalABC.NET/Maze-generation
@@ -0,0 +1 @@
+../../Task/Maze-generation/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/McNuggets-problem b/Lang/PascalABC.NET/McNuggets-problem
new file mode 120000
index 0000000000..ceb4630090
--- /dev/null
+++ b/Lang/PascalABC.NET/McNuggets-problem
@@ -0,0 +1 @@
+../../Task/McNuggets-problem/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Meissel-Mertens-constant b/Lang/PascalABC.NET/Meissel-Mertens-constant
new file mode 120000
index 0000000000..96e15ce1b8
--- /dev/null
+++ b/Lang/PascalABC.NET/Meissel-Mertens-constant
@@ -0,0 +1 @@
+../../Task/Meissel-Mertens-constant/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Mertens-function b/Lang/PascalABC.NET/Mertens-function
new file mode 120000
index 0000000000..f3e21033e6
--- /dev/null
+++ b/Lang/PascalABC.NET/Mertens-function
@@ -0,0 +1 @@
+../../Task/Mertens-function/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Metallic-ratios b/Lang/PascalABC.NET/Metallic-ratios
new file mode 120000
index 0000000000..1f47416b87
--- /dev/null
+++ b/Lang/PascalABC.NET/Metallic-ratios
@@ -0,0 +1 @@
+../../Task/Metallic-ratios/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Metered-concurrency b/Lang/PascalABC.NET/Metered-concurrency
new file mode 120000
index 0000000000..925b288d53
--- /dev/null
+++ b/Lang/PascalABC.NET/Metered-concurrency
@@ -0,0 +1 @@
+../../Task/Metered-concurrency/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Mian-Chowla-sequence b/Lang/PascalABC.NET/Mian-Chowla-sequence
new file mode 120000
index 0000000000..8a0250e208
--- /dev/null
+++ b/Lang/PascalABC.NET/Mian-Chowla-sequence
@@ -0,0 +1 @@
+../../Task/Mian-Chowla-sequence/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Middle-three-digits b/Lang/PascalABC.NET/Middle-three-digits
new file mode 120000
index 0000000000..5e135c1794
--- /dev/null
+++ b/Lang/PascalABC.NET/Middle-three-digits
@@ -0,0 +1 @@
+../../Task/Middle-three-digits/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Miller-Rabin-primality-test b/Lang/PascalABC.NET/Miller-Rabin-primality-test
new file mode 120000
index 0000000000..629803a659
--- /dev/null
+++ b/Lang/PascalABC.NET/Miller-Rabin-primality-test
@@ -0,0 +1 @@
+../../Task/Miller-Rabin-primality-test/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Minimum-multiple-of-m-where-digital-sum-equals-m b/Lang/PascalABC.NET/Minimum-multiple-of-m-where-digital-sum-equals-m
new file mode 120000
index 0000000000..97c186fb9d
--- /dev/null
+++ b/Lang/PascalABC.NET/Minimum-multiple-of-m-where-digital-sum-equals-m
@@ -0,0 +1 @@
+../../Task/Minimum-multiple-of-m-where-digital-sum-equals-m/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Modified-random-distribution b/Lang/PascalABC.NET/Modified-random-distribution
new file mode 120000
index 0000000000..0b45ed8c91
--- /dev/null
+++ b/Lang/PascalABC.NET/Modified-random-distribution
@@ -0,0 +1 @@
+../../Task/Modified-random-distribution/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Modular-inverse b/Lang/PascalABC.NET/Modular-inverse
new file mode 120000
index 0000000000..cf592b925c
--- /dev/null
+++ b/Lang/PascalABC.NET/Modular-inverse
@@ -0,0 +1 @@
+../../Task/Modular-inverse/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Monty-Hall-problem b/Lang/PascalABC.NET/Monty-Hall-problem
new file mode 120000
index 0000000000..194ee5c033
--- /dev/null
+++ b/Lang/PascalABC.NET/Monty-Hall-problem
@@ -0,0 +1 @@
+../../Task/Monty-Hall-problem/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Morse-code b/Lang/PascalABC.NET/Morse-code
new file mode 120000
index 0000000000..957358167f
--- /dev/null
+++ b/Lang/PascalABC.NET/Morse-code
@@ -0,0 +1 @@
+../../Task/Morse-code/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Motzkin-numbers b/Lang/PascalABC.NET/Motzkin-numbers
new file mode 120000
index 0000000000..119a6ee6b9
--- /dev/null
+++ b/Lang/PascalABC.NET/Motzkin-numbers
@@ -0,0 +1 @@
+../../Task/Motzkin-numbers/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Move-to-front-algorithm b/Lang/PascalABC.NET/Move-to-front-algorithm
new file mode 120000
index 0000000000..e365638bb3
--- /dev/null
+++ b/Lang/PascalABC.NET/Move-to-front-algorithm
@@ -0,0 +1 @@
+../../Task/Move-to-front-algorithm/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Multifactorial b/Lang/PascalABC.NET/Multifactorial
new file mode 120000
index 0000000000..1a4d72f284
--- /dev/null
+++ b/Lang/PascalABC.NET/Multifactorial
@@ -0,0 +1 @@
+../../Task/Multifactorial/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Multiple-regression b/Lang/PascalABC.NET/Multiple-regression
new file mode 120000
index 0000000000..c2b1f827d2
--- /dev/null
+++ b/Lang/PascalABC.NET/Multiple-regression
@@ -0,0 +1 @@
+../../Task/Multiple-regression/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Munchausen-numbers b/Lang/PascalABC.NET/Munchausen-numbers
new file mode 120000
index 0000000000..e5388bf0cf
--- /dev/null
+++ b/Lang/PascalABC.NET/Munchausen-numbers
@@ -0,0 +1 @@
+../../Task/Munchausen-numbers/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Musical-scale b/Lang/PascalABC.NET/Musical-scale
new file mode 120000
index 0000000000..33d370124c
--- /dev/null
+++ b/Lang/PascalABC.NET/Musical-scale
@@ -0,0 +1 @@
+../../Task/Musical-scale/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/N-queens-problem b/Lang/PascalABC.NET/N-queens-problem
new file mode 120000
index 0000000000..d0df5430cc
--- /dev/null
+++ b/Lang/PascalABC.NET/N-queens-problem
@@ -0,0 +1 @@
+../../Task/N-queens-problem/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Named-parameters b/Lang/PascalABC.NET/Named-parameters
new file mode 120000
index 0000000000..f91e295fc0
--- /dev/null
+++ b/Lang/PascalABC.NET/Named-parameters
@@ -0,0 +1 @@
+../../Task/Named-parameters/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Narcissistic-decimal-number b/Lang/PascalABC.NET/Narcissistic-decimal-number
new file mode 120000
index 0000000000..6e25078669
--- /dev/null
+++ b/Lang/PascalABC.NET/Narcissistic-decimal-number
@@ -0,0 +1 @@
+../../Task/Narcissistic-decimal-number/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Next-highest-int-from-digits b/Lang/PascalABC.NET/Next-highest-int-from-digits
new file mode 120000
index 0000000000..f57c5311ba
--- /dev/null
+++ b/Lang/PascalABC.NET/Next-highest-int-from-digits
@@ -0,0 +1 @@
+../../Task/Next-highest-int-from-digits/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Nim-game b/Lang/PascalABC.NET/Nim-game
new file mode 120000
index 0000000000..11fed8b04f
--- /dev/null
+++ b/Lang/PascalABC.NET/Nim-game
@@ -0,0 +1 @@
+../../Task/Nim-game/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Non-continuous-subsequences b/Lang/PascalABC.NET/Non-continuous-subsequences
new file mode 120000
index 0000000000..fb90313f8e
--- /dev/null
+++ b/Lang/PascalABC.NET/Non-continuous-subsequences
@@ -0,0 +1 @@
+../../Task/Non-continuous-subsequences/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Nonoblock b/Lang/PascalABC.NET/Nonoblock
new file mode 120000
index 0000000000..27ec8aac45
--- /dev/null
+++ b/Lang/PascalABC.NET/Nonoblock
@@ -0,0 +1 @@
+../../Task/Nonoblock/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Numbers-which-are-not-the-sum-of-distinct-squares b/Lang/PascalABC.NET/Numbers-which-are-not-the-sum-of-distinct-squares
new file mode 120000
index 0000000000..11f633b289
--- /dev/null
+++ b/Lang/PascalABC.NET/Numbers-which-are-not-the-sum-of-distinct-squares
@@ -0,0 +1 @@
+../../Task/Numbers-which-are-not-the-sum-of-distinct-squares/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Numbers-which-are-the-cube-roots-of-the-product-of-their-proper-divisors b/Lang/PascalABC.NET/Numbers-which-are-the-cube-roots-of-the-product-of-their-proper-divisors
new file mode 120000
index 0000000000..3b98dabeae
--- /dev/null
+++ b/Lang/PascalABC.NET/Numbers-which-are-the-cube-roots-of-the-product-of-their-proper-divisors
@@ -0,0 +1 @@
+../../Task/Numbers-which-are-the-cube-roots-of-the-product-of-their-proper-divisors/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Numbers-with-equal-rises-and-falls b/Lang/PascalABC.NET/Numbers-with-equal-rises-and-falls
new file mode 120000
index 0000000000..265a6e57f2
--- /dev/null
+++ b/Lang/PascalABC.NET/Numbers-with-equal-rises-and-falls
@@ -0,0 +1 @@
+../../Task/Numbers-with-equal-rises-and-falls/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Numeric-error-propagation b/Lang/PascalABC.NET/Numeric-error-propagation
new file mode 120000
index 0000000000..b8b2e6d9b5
--- /dev/null
+++ b/Lang/PascalABC.NET/Numeric-error-propagation
@@ -0,0 +1 @@
+../../Task/Numeric-error-propagation/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Numerical-integration b/Lang/PascalABC.NET/Numerical-integration
new file mode 120000
index 0000000000..dc5bfcc884
--- /dev/null
+++ b/Lang/PascalABC.NET/Numerical-integration
@@ -0,0 +1 @@
+../../Task/Numerical-integration/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Odd-word-problem b/Lang/PascalABC.NET/Odd-word-problem
new file mode 120000
index 0000000000..b0936fb34b
--- /dev/null
+++ b/Lang/PascalABC.NET/Odd-word-problem
@@ -0,0 +1 @@
+../../Task/Odd-word-problem/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/One-dimensional-cellular-automata b/Lang/PascalABC.NET/One-dimensional-cellular-automata
new file mode 120000
index 0000000000..19b52c40ec
--- /dev/null
+++ b/Lang/PascalABC.NET/One-dimensional-cellular-automata
@@ -0,0 +1 @@
+../../Task/One-dimensional-cellular-automata/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/One-of-n-lines-in-a-file b/Lang/PascalABC.NET/One-of-n-lines-in-a-file
new file mode 120000
index 0000000000..6a1426ac8c
--- /dev/null
+++ b/Lang/PascalABC.NET/One-of-n-lines-in-a-file
@@ -0,0 +1 @@
+../../Task/One-of-n-lines-in-a-file/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/OpenWebNet-password b/Lang/PascalABC.NET/OpenWebNet-password
new file mode 120000
index 0000000000..41ce8aa36a
--- /dev/null
+++ b/Lang/PascalABC.NET/OpenWebNet-password
@@ -0,0 +1 @@
+../../Task/OpenWebNet-password/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Operator-precedence b/Lang/PascalABC.NET/Operator-precedence
new file mode 120000
index 0000000000..08a1b040c3
--- /dev/null
+++ b/Lang/PascalABC.NET/Operator-precedence
@@ -0,0 +1 @@
+../../Task/Operator-precedence/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Order-two-numerical-lists b/Lang/PascalABC.NET/Order-two-numerical-lists
new file mode 120000
index 0000000000..8f392c8ff3
--- /dev/null
+++ b/Lang/PascalABC.NET/Order-two-numerical-lists
@@ -0,0 +1 @@
+../../Task/Order-two-numerical-lists/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Padovan-n-step-number-sequences b/Lang/PascalABC.NET/Padovan-n-step-number-sequences
new file mode 120000
index 0000000000..2e49ed2259
--- /dev/null
+++ b/Lang/PascalABC.NET/Padovan-n-step-number-sequences
@@ -0,0 +1 @@
+../../Task/Padovan-n-step-number-sequences/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Padovan-sequence b/Lang/PascalABC.NET/Padovan-sequence
new file mode 120000
index 0000000000..c2c68fb6dd
--- /dev/null
+++ b/Lang/PascalABC.NET/Padovan-sequence
@@ -0,0 +1 @@
+../../Task/Padovan-sequence/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Palindrome-dates b/Lang/PascalABC.NET/Palindrome-dates
new file mode 120000
index 0000000000..09644b6a7c
--- /dev/null
+++ b/Lang/PascalABC.NET/Palindrome-dates
@@ -0,0 +1 @@
+../../Task/Palindrome-dates/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Palindromic-gapful-numbers b/Lang/PascalABC.NET/Palindromic-gapful-numbers
new file mode 120000
index 0000000000..532e5bda78
--- /dev/null
+++ b/Lang/PascalABC.NET/Palindromic-gapful-numbers
@@ -0,0 +1 @@
+../../Task/Palindromic-gapful-numbers/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Permutations-Derangements b/Lang/PascalABC.NET/Permutations-Derangements
new file mode 120000
index 0000000000..4c7dd2b64b
--- /dev/null
+++ b/Lang/PascalABC.NET/Permutations-Derangements
@@ -0,0 +1 @@
+../../Task/Permutations-Derangements/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Roots-of-unity b/Lang/PascalABC.NET/Roots-of-unity
new file mode 120000
index 0000000000..31b7a73b39
--- /dev/null
+++ b/Lang/PascalABC.NET/Roots-of-unity
@@ -0,0 +1 @@
+../../Task/Roots-of-unity/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/PascalABC.NET/Totient-function b/Lang/PascalABC.NET/Totient-function
new file mode 120000
index 0000000000..cbbd5dcdf5
--- /dev/null
+++ b/Lang/PascalABC.NET/Totient-function
@@ -0,0 +1 @@
+../../Task/Totient-function/PascalABC.NET
\ No newline at end of file
diff --git a/Lang/Plain-English/00-LANG.txt b/Lang/Plain-English/00-LANG.txt
index 879e8b69bc..be0ed94cc3 100644
--- a/Lang/Plain-English/00-LANG.txt
+++ b/Lang/Plain-English/00-LANG.txt
@@ -244,6 +244,8 @@ https://forums.parallax.com/discussion/163792/plain-english-programming a long r
* Complete IDE Download
** [http://www.Osmosian.com/cal-4700.zip cal-4700.zip]
*** requires Microsoft Windows
+* Plain English Compiler (CMD / Command Line)
+** [https://github.com/elisson-zlq3x/Plain-English-Compiler GitHub repo]
==Discussion==
* [https://forums.parallax.com/discussion/163792/plain-english-programming Plain English Programming]
diff --git a/Lang/PureBasic/ASCII-art-diagram-converter b/Lang/PureBasic/ASCII-art-diagram-converter
new file mode 120000
index 0000000000..33f4c7eea5
--- /dev/null
+++ b/Lang/PureBasic/ASCII-art-diagram-converter
@@ -0,0 +1 @@
+../../Task/ASCII-art-diagram-converter/PureBasic
\ No newline at end of file
diff --git a/Lang/PureBasic/Blum-integer b/Lang/PureBasic/Blum-integer
new file mode 120000
index 0000000000..d3f0a3d564
--- /dev/null
+++ b/Lang/PureBasic/Blum-integer
@@ -0,0 +1 @@
+../../Task/Blum-integer/PureBasic
\ No newline at end of file
diff --git a/Lang/PureBasic/Generate-Chess960-starting-position b/Lang/PureBasic/Generate-Chess960-starting-position
new file mode 120000
index 0000000000..d1a0ea8b2a
--- /dev/null
+++ b/Lang/PureBasic/Generate-Chess960-starting-position
@@ -0,0 +1 @@
+../../Task/Generate-Chess960-starting-position/PureBasic
\ No newline at end of file
diff --git a/Lang/Python/Compile-time-calculation b/Lang/Python/Compile-time-calculation
new file mode 120000
index 0000000000..33879ac69d
--- /dev/null
+++ b/Lang/Python/Compile-time-calculation
@@ -0,0 +1 @@
+../../Task/Compile-time-calculation/Python
\ No newline at end of file
diff --git a/Lang/Python/Constrained-genericity b/Lang/Python/Constrained-genericity
new file mode 120000
index 0000000000..3ac238c57a
--- /dev/null
+++ b/Lang/Python/Constrained-genericity
@@ -0,0 +1 @@
+../../Task/Constrained-genericity/Python
\ No newline at end of file
diff --git a/Lang/Python/Erd-s-Selfridge-categorization-of-primes b/Lang/Python/Erd-s-Selfridge-categorization-of-primes
new file mode 120000
index 0000000000..fd2fdbcb3f
--- /dev/null
+++ b/Lang/Python/Erd-s-Selfridge-categorization-of-primes
@@ -0,0 +1 @@
+../../Task/Erd-s-Selfridge-categorization-of-primes/Python
\ No newline at end of file
diff --git a/Lang/Python/Isograms-and-heterograms b/Lang/Python/Isograms-and-heterograms
new file mode 120000
index 0000000000..f277330152
--- /dev/null
+++ b/Lang/Python/Isograms-and-heterograms
@@ -0,0 +1 @@
+../../Task/Isograms-and-heterograms/Python
\ No newline at end of file
diff --git a/Lang/Python/Multi-base-primes b/Lang/Python/Multi-base-primes
new file mode 120000
index 0000000000..6190bc944f
--- /dev/null
+++ b/Lang/Python/Multi-base-primes
@@ -0,0 +1 @@
+../../Task/Multi-base-primes/Python
\ No newline at end of file
diff --git a/Lang/Python/Numbers-which-are-not-the-sum-of-distinct-squares b/Lang/Python/Numbers-which-are-not-the-sum-of-distinct-squares
new file mode 120000
index 0000000000..3a47a71cf2
--- /dev/null
+++ b/Lang/Python/Numbers-which-are-not-the-sum-of-distinct-squares
@@ -0,0 +1 @@
+../../Task/Numbers-which-are-not-the-sum-of-distinct-squares/Python
\ No newline at end of file
diff --git a/Lang/Python/Parametric-polymorphism b/Lang/Python/Parametric-polymorphism
new file mode 120000
index 0000000000..b6d5668cdf
--- /dev/null
+++ b/Lang/Python/Parametric-polymorphism
@@ -0,0 +1 @@
+../../Task/Parametric-polymorphism/Python
\ No newline at end of file
diff --git a/Lang/Python/Peripheral-drift-illusion b/Lang/Python/Peripheral-drift-illusion
new file mode 120000
index 0000000000..4e0e7d7c77
--- /dev/null
+++ b/Lang/Python/Peripheral-drift-illusion
@@ -0,0 +1 @@
+../../Task/Peripheral-drift-illusion/Python
\ No newline at end of file
diff --git a/Lang/Python/Ramanujan-primes-twins b/Lang/Python/Ramanujan-primes-twins
new file mode 120000
index 0000000000..8b76bc210b
--- /dev/null
+++ b/Lang/Python/Ramanujan-primes-twins
@@ -0,0 +1 @@
+../../Task/Ramanujan-primes-twins/Python
\ No newline at end of file
diff --git a/Lang/Python/Untouchable-numbers b/Lang/Python/Untouchable-numbers
new file mode 120000
index 0000000000..c4bd0ba9e1
--- /dev/null
+++ b/Lang/Python/Untouchable-numbers
@@ -0,0 +1 @@
+../../Task/Untouchable-numbers/Python
\ No newline at end of file
diff --git a/Lang/QB64/Blum-integer b/Lang/QB64/Blum-integer
new file mode 120000
index 0000000000..6d55cd1ae1
--- /dev/null
+++ b/Lang/QB64/Blum-integer
@@ -0,0 +1 @@
+../../Task/Blum-integer/QB64
\ No newline at end of file
diff --git a/Lang/QBasic/00-LANG.txt b/Lang/QBasic/00-LANG.txt
index 4ab26db45d..66c4f1d834 100644
--- a/Lang/QBasic/00-LANG.txt
+++ b/Lang/QBasic/00-LANG.txt
@@ -1,3 +1,4 @@
{{language}}
+{{implementation|BASIC}}
QBasic is a BASIC that was written by Microsoft and normally executes under Windows.
\ No newline at end of file
diff --git a/Lang/QBasic/15-puzzle-game b/Lang/QBasic/15-puzzle-game
new file mode 120000
index 0000000000..4cdffaba3f
--- /dev/null
+++ b/Lang/QBasic/15-puzzle-game
@@ -0,0 +1 @@
+../../Task/15-puzzle-game/QBasic
\ No newline at end of file
diff --git a/Lang/QBasic/ASCII-art-diagram-converter b/Lang/QBasic/ASCII-art-diagram-converter
new file mode 120000
index 0000000000..75bc551903
--- /dev/null
+++ b/Lang/QBasic/ASCII-art-diagram-converter
@@ -0,0 +1 @@
+../../Task/ASCII-art-diagram-converter/QBasic
\ No newline at end of file
diff --git a/Lang/QBasic/Horizontal-sundial-calculations b/Lang/QBasic/Horizontal-sundial-calculations
new file mode 120000
index 0000000000..48a7ed5986
--- /dev/null
+++ b/Lang/QBasic/Horizontal-sundial-calculations
@@ -0,0 +1 @@
+../../Task/Horizontal-sundial-calculations/QBasic
\ No newline at end of file
diff --git a/Lang/Quackery/00-LANG.txt b/Lang/Quackery/00-LANG.txt
index e36ac3a936..c6437e7156 100644
--- a/Lang/Quackery/00-LANG.txt
+++ b/Lang/Quackery/00-LANG.txt
@@ -1,9 +1,9 @@
{{language|Quackery}}
{{language programming paradigm|Concatenative}}
{{language programming paradigm|Imperative}}
-Quackery is an open-source, lightweight, entry-level concatenative language for educational and recreational programming.
+Quackery is an open-source, lightweight, entry-level concatenative language for educational and recreational programming, and an extensible compiler for a hypothetical processor, the Quackery Engine.
-It is coded as a Python 3 function in under 48k of Pythonscript, about half of which is a string of Quackery code.
+It is coded as a Python 3 function in about 48k of Pythonscript, about half of which is a string of Quackery code.
The Quackery GitHub repository, which includes the Quackery manual "The Book of Quackery" as a pdf, is at [https://github.com/GordonCharlton/Quackery github.com/GordonCharlton/Quackery].
@@ -27,8 +27,6 @@ Everything is code except when it is data. When do does a number, t
Conceptually, the Quackery engine is a stack based processor which does not have direct access to physical memory but has a memory management co-processor that intermediates, that takes care of the nests and bignums, provides pointers to the Quackery engine CPU on request, and garbage collects continuously.
-Quackery is not intended to be a super-fast enterprise-level language; it is intended as a fun programming project straight out of a textbook. (The textbook is included in the download.)
+Quackery is not intended to be a super-fast enterprise-level language; it is intended as an exploration of a novel architecture, and a fun programming project straight out of a textbook. (The textbook is included in the download.)
-If your language supports bignums, first-class functions and dynamic arrays of bignums, functions and dynamic arrays, and has automatic garbage collection, and if you can code depth-first traversal of a tree you can implement Quackery in your preferred language with reasonable ease, and modify it as you please.
-
-Or try your hand at one of the [[Tasks not implemented in Quackery]].
\ No newline at end of file
+Why not try your hand at one of the [[Tasks not implemented in Quackery]].
\ No newline at end of file
diff --git a/Lang/Quackery/4-rings-or-4-squares-puzzle b/Lang/Quackery/4-rings-or-4-squares-puzzle
new file mode 120000
index 0000000000..786cc93b7f
--- /dev/null
+++ b/Lang/Quackery/4-rings-or-4-squares-puzzle
@@ -0,0 +1 @@
+../../Task/4-rings-or-4-squares-puzzle/Quackery
\ No newline at end of file
diff --git a/Lang/Quackery/Benfords-law b/Lang/Quackery/Benfords-law
new file mode 120000
index 0000000000..83c8fdffec
--- /dev/null
+++ b/Lang/Quackery/Benfords-law
@@ -0,0 +1 @@
+../../Task/Benfords-law/Quackery
\ No newline at end of file
diff --git a/Lang/Quackery/Chowla-numbers b/Lang/Quackery/Chowla-numbers
new file mode 120000
index 0000000000..017749c553
--- /dev/null
+++ b/Lang/Quackery/Chowla-numbers
@@ -0,0 +1 @@
+../../Task/Chowla-numbers/Quackery
\ No newline at end of file
diff --git a/Lang/Quackery/Combinations-and-permutations b/Lang/Quackery/Combinations-and-permutations
new file mode 120000
index 0000000000..fc6f331f4d
--- /dev/null
+++ b/Lang/Quackery/Combinations-and-permutations
@@ -0,0 +1 @@
+../../Task/Combinations-and-permutations/Quackery
\ No newline at end of file
diff --git a/Lang/Quackery/Cuban-primes b/Lang/Quackery/Cuban-primes
new file mode 120000
index 0000000000..8c512d4853
--- /dev/null
+++ b/Lang/Quackery/Cuban-primes
@@ -0,0 +1 @@
+../../Task/Cuban-primes/Quackery
\ No newline at end of file
diff --git a/Lang/Quackery/Doomsday-rule b/Lang/Quackery/Doomsday-rule
new file mode 120000
index 0000000000..f3df2f0b9b
--- /dev/null
+++ b/Lang/Quackery/Doomsday-rule
@@ -0,0 +1 @@
+../../Task/Doomsday-rule/Quackery
\ No newline at end of file
diff --git a/Lang/Quackery/Execute-Computer-Zero b/Lang/Quackery/Execute-Computer-Zero
new file mode 120000
index 0000000000..bffceead11
--- /dev/null
+++ b/Lang/Quackery/Execute-Computer-Zero
@@ -0,0 +1 @@
+../../Task/Execute-Computer-Zero/Quackery
\ No newline at end of file
diff --git a/Lang/Quackery/First-class-functions-Use-numbers-analogously b/Lang/Quackery/First-class-functions-Use-numbers-analogously
new file mode 120000
index 0000000000..c8416f6780
--- /dev/null
+++ b/Lang/Quackery/First-class-functions-Use-numbers-analogously
@@ -0,0 +1 @@
+../../Task/First-class-functions-Use-numbers-analogously/Quackery
\ No newline at end of file
diff --git a/Lang/Quackery/Golden-ratio-Convergence b/Lang/Quackery/Golden-ratio-Convergence
new file mode 120000
index 0000000000..177994dc3e
--- /dev/null
+++ b/Lang/Quackery/Golden-ratio-Convergence
@@ -0,0 +1 @@
+../../Task/Golden-ratio-Convergence/Quackery
\ No newline at end of file
diff --git a/Lang/Quackery/Menu b/Lang/Quackery/Menu
new file mode 120000
index 0000000000..07087595bc
--- /dev/null
+++ b/Lang/Quackery/Menu
@@ -0,0 +1 @@
+../../Task/Menu/Quackery
\ No newline at end of file
diff --git a/Lang/Quackery/Old-lady-swallowed-a-fly b/Lang/Quackery/Old-lady-swallowed-a-fly
new file mode 120000
index 0000000000..0d6823a2fd
--- /dev/null
+++ b/Lang/Quackery/Old-lady-swallowed-a-fly
@@ -0,0 +1 @@
+../../Task/Old-lady-swallowed-a-fly/Quackery
\ No newline at end of file
diff --git a/Lang/Quackery/Pseudo-random-numbers-Xorshift-star b/Lang/Quackery/Pseudo-random-numbers-Xorshift-star
new file mode 120000
index 0000000000..0d802ea7eb
--- /dev/null
+++ b/Lang/Quackery/Pseudo-random-numbers-Xorshift-star
@@ -0,0 +1 @@
+../../Task/Pseudo-random-numbers-Xorshift-star/Quackery
\ No newline at end of file
diff --git a/Lang/Quackery/Sleep b/Lang/Quackery/Sleep
new file mode 120000
index 0000000000..7cd0464b5f
--- /dev/null
+++ b/Lang/Quackery/Sleep
@@ -0,0 +1 @@
+../../Task/Sleep/Quackery
\ No newline at end of file
diff --git a/Lang/Quackery/Square-free-integers b/Lang/Quackery/Square-free-integers
new file mode 120000
index 0000000000..1d2a5a3f4e
--- /dev/null
+++ b/Lang/Quackery/Square-free-integers
@@ -0,0 +1 @@
+../../Task/Square-free-integers/Quackery
\ No newline at end of file
diff --git a/Lang/Quackery/Ultra-useful-primes b/Lang/Quackery/Ultra-useful-primes
new file mode 120000
index 0000000000..d6fc3551e1
--- /dev/null
+++ b/Lang/Quackery/Ultra-useful-primes
@@ -0,0 +1 @@
+../../Task/Ultra-useful-primes/Quackery
\ No newline at end of file
diff --git a/Lang/Quackery/Universal-Turing-machine b/Lang/Quackery/Universal-Turing-machine
new file mode 120000
index 0000000000..9346211d7e
--- /dev/null
+++ b/Lang/Quackery/Universal-Turing-machine
@@ -0,0 +1 @@
+../../Task/Universal-Turing-machine/Quackery
\ No newline at end of file
diff --git a/Lang/QuickBASIC/Nth-root b/Lang/QuickBASIC/Nth-root
new file mode 120000
index 0000000000..db6d881466
--- /dev/null
+++ b/Lang/QuickBASIC/Nth-root
@@ -0,0 +1 @@
+../../Task/Nth-root/QuickBASIC
\ No newline at end of file
diff --git a/Lang/R/Quickselect-algorithm b/Lang/R/Quickselect-algorithm
new file mode 120000
index 0000000000..996073d670
--- /dev/null
+++ b/Lang/R/Quickselect-algorithm
@@ -0,0 +1 @@
+../../Task/Quickselect-algorithm/R
\ No newline at end of file
diff --git a/Lang/REXX/Legendre-prime-counting-function b/Lang/REXX/Legendre-prime-counting-function
new file mode 120000
index 0000000000..74d1b424e1
--- /dev/null
+++ b/Lang/REXX/Legendre-prime-counting-function
@@ -0,0 +1 @@
+../../Task/Legendre-prime-counting-function/REXX
\ No newline at end of file
diff --git a/Lang/RTL-2/00-LANG.txt b/Lang/RTL-2/00-LANG.txt
index da5b7b1776..1ed7c9f33f 100644
--- a/Lang/RTL-2/00-LANG.txt
+++ b/Lang/RTL-2/00-LANG.txt
@@ -52,6 +52,9 @@ While the specifics varied by operating system the following is an example of a
This code insert moves the value of a variable passed into the RTL/2 procedure into a variable called COUNTER in a data brick called MYDATA.
+== Design and Rationale ==
+J. G. P. Barnes describes RTL/2 and the reasons behind some of the design decisions made during its development in his 1976 book RTL/2 Design and Philosophy.
+
== Reserved Words ==
ABS
AND
diff --git a/Lang/Racket/Twos-complement b/Lang/Racket/Twos-complement
new file mode 120000
index 0000000000..0d85b62ede
--- /dev/null
+++ b/Lang/Racket/Twos-complement
@@ -0,0 +1 @@
+../../Task/Twos-complement/Racket
\ No newline at end of file
diff --git a/Lang/Raku/Dominoes b/Lang/Raku/Dominoes
new file mode 120000
index 0000000000..48ba3c99bf
--- /dev/null
+++ b/Lang/Raku/Dominoes
@@ -0,0 +1 @@
+../../Task/Dominoes/Raku
\ No newline at end of file
diff --git a/Lang/RapidQ/Nth-root b/Lang/RapidQ/Nth-root
new file mode 120000
index 0000000000..f4c270323f
--- /dev/null
+++ b/Lang/RapidQ/Nth-root
@@ -0,0 +1 @@
+../../Task/Nth-root/RapidQ
\ No newline at end of file
diff --git a/Lang/RapidQ/Temperature-conversion b/Lang/RapidQ/Temperature-conversion
new file mode 120000
index 0000000000..757db1c288
--- /dev/null
+++ b/Lang/RapidQ/Temperature-conversion
@@ -0,0 +1 @@
+../../Task/Temperature-conversion/RapidQ
\ No newline at end of file
diff --git a/Lang/Red/Rosetta-Code-Find-unimplemented-tasks b/Lang/Red/Rosetta-Code-Find-unimplemented-tasks
new file mode 120000
index 0000000000..53726178b5
--- /dev/null
+++ b/Lang/Red/Rosetta-Code-Find-unimplemented-tasks
@@ -0,0 +1 @@
+../../Task/Rosetta-Code-Find-unimplemented-tasks/Red
\ No newline at end of file
diff --git a/Lang/Refal/Align-columns b/Lang/Refal/Align-columns
new file mode 120000
index 0000000000..8c214d7af1
--- /dev/null
+++ b/Lang/Refal/Align-columns
@@ -0,0 +1 @@
+../../Task/Align-columns/Refal
\ No newline at end of file
diff --git a/Lang/Refal/Arithmetic-derivative b/Lang/Refal/Arithmetic-derivative
new file mode 120000
index 0000000000..c88f60d44d
--- /dev/null
+++ b/Lang/Refal/Arithmetic-derivative
@@ -0,0 +1 @@
+../../Task/Arithmetic-derivative/Refal
\ No newline at end of file
diff --git a/Lang/Refal/Bell-numbers b/Lang/Refal/Bell-numbers
new file mode 120000
index 0000000000..a73ced2740
--- /dev/null
+++ b/Lang/Refal/Bell-numbers
@@ -0,0 +1 @@
+../../Task/Bell-numbers/Refal
\ No newline at end of file
diff --git a/Lang/Refal/Doomsday-rule b/Lang/Refal/Doomsday-rule
new file mode 120000
index 0000000000..87fb488eaa
--- /dev/null
+++ b/Lang/Refal/Doomsday-rule
@@ -0,0 +1 @@
+../../Task/Doomsday-rule/Refal
\ No newline at end of file
diff --git a/Lang/Refal/Duffinian-numbers b/Lang/Refal/Duffinian-numbers
new file mode 120000
index 0000000000..7aec5bb21b
--- /dev/null
+++ b/Lang/Refal/Duffinian-numbers
@@ -0,0 +1 @@
+../../Task/Duffinian-numbers/Refal
\ No newline at end of file
diff --git a/Lang/Refal/Horners-rule-for-polynomial-evaluation b/Lang/Refal/Horners-rule-for-polynomial-evaluation
new file mode 120000
index 0000000000..29b0a0f26a
--- /dev/null
+++ b/Lang/Refal/Horners-rule-for-polynomial-evaluation
@@ -0,0 +1 @@
+../../Task/Horners-rule-for-polynomial-evaluation/Refal
\ No newline at end of file
diff --git a/Lang/Refal/Isqrt-integer-square-root-of-X b/Lang/Refal/Isqrt-integer-square-root-of-X
new file mode 120000
index 0000000000..812b5e86d3
--- /dev/null
+++ b/Lang/Refal/Isqrt-integer-square-root-of-X
@@ -0,0 +1 @@
+../../Task/Isqrt-integer-square-root-of-X/Refal
\ No newline at end of file
diff --git a/Lang/Refal/Lah-numbers b/Lang/Refal/Lah-numbers
new file mode 120000
index 0000000000..a761f59719
--- /dev/null
+++ b/Lang/Refal/Lah-numbers
@@ -0,0 +1 @@
+../../Task/Lah-numbers/Refal
\ No newline at end of file
diff --git a/Lang/Refal/Roman-numerals-Encode b/Lang/Refal/Roman-numerals-Encode
new file mode 120000
index 0000000000..a35e7a2ee0
--- /dev/null
+++ b/Lang/Refal/Roman-numerals-Encode
@@ -0,0 +1 @@
+../../Task/Roman-numerals-Encode/Refal
\ No newline at end of file
diff --git a/Lang/Retro/Sieve-of-Eratosthenes b/Lang/Retro/Sieve-of-Eratosthenes
new file mode 120000
index 0000000000..d5617b7054
--- /dev/null
+++ b/Lang/Retro/Sieve-of-Eratosthenes
@@ -0,0 +1 @@
+../../Task/Sieve-of-Eratosthenes/Retro
\ No newline at end of file
diff --git a/Lang/Retro/String-append b/Lang/Retro/String-append
new file mode 120000
index 0000000000..db032f3f0a
--- /dev/null
+++ b/Lang/Retro/String-append
@@ -0,0 +1 @@
+../../Task/String-append/Retro
\ No newline at end of file
diff --git a/Lang/Retro/Sum-multiples-of-3-and-5 b/Lang/Retro/Sum-multiples-of-3-and-5
new file mode 120000
index 0000000000..cb0c42540d
--- /dev/null
+++ b/Lang/Retro/Sum-multiples-of-3-and-5
@@ -0,0 +1 @@
+../../Task/Sum-multiples-of-3-and-5/Retro
\ No newline at end of file
diff --git a/Lang/Ring/Special-characters b/Lang/Ring/Special-characters
new file mode 120000
index 0000000000..0dd3c257c9
--- /dev/null
+++ b/Lang/Ring/Special-characters
@@ -0,0 +1 @@
+../../Task/Special-characters/Ring
\ No newline at end of file
diff --git a/Lang/Ring/Wieferich-primes b/Lang/Ring/Wieferich-primes
new file mode 120000
index 0000000000..4a7c97a04d
--- /dev/null
+++ b/Lang/Ring/Wieferich-primes
@@ -0,0 +1 @@
+../../Task/Wieferich-primes/Ring
\ No newline at end of file
diff --git a/Lang/S-BASIC/00-LANG.txt b/Lang/S-BASIC/00-LANG.txt
index 7e71ba9085..cb4f4a5c14 100644
--- a/Lang/S-BASIC/00-LANG.txt
+++ b/Lang/S-BASIC/00-LANG.txt
@@ -1,4 +1,5 @@
{{stub}}{{language|S-BASIC}}
+{{implementation|BASIC}}
S-BASIC (the S stands for "structured") was a native-code
compiler for an ALGOL-like dialect of the BASIC programming
language, and ran on 8-bit microcomputers using the Z80 CPU and
diff --git a/Lang/S-BASIC/Square-free-integers b/Lang/S-BASIC/Square-free-integers
new file mode 120000
index 0000000000..d6296e2f26
--- /dev/null
+++ b/Lang/S-BASIC/Square-free-integers
@@ -0,0 +1 @@
+../../Task/Square-free-integers/S-BASIC
\ No newline at end of file
diff --git a/Lang/S-BASIC/String-interpolation-included- b/Lang/S-BASIC/String-interpolation-included-
new file mode 120000
index 0000000000..c71873859b
--- /dev/null
+++ b/Lang/S-BASIC/String-interpolation-included-
@@ -0,0 +1 @@
+../../Task/String-interpolation-included-/S-BASIC
\ No newline at end of file
diff --git a/Lang/SETL/Arithmetic-derivative b/Lang/SETL/Arithmetic-derivative
new file mode 120000
index 0000000000..56f987cef7
--- /dev/null
+++ b/Lang/SETL/Arithmetic-derivative
@@ -0,0 +1 @@
+../../Task/Arithmetic-derivative/SETL
\ No newline at end of file
diff --git a/Lang/SETL/Bell-numbers b/Lang/SETL/Bell-numbers
new file mode 120000
index 0000000000..32b1473efe
--- /dev/null
+++ b/Lang/SETL/Bell-numbers
@@ -0,0 +1 @@
+../../Task/Bell-numbers/SETL
\ No newline at end of file
diff --git a/Lang/SETL/Doomsday-rule b/Lang/SETL/Doomsday-rule
new file mode 120000
index 0000000000..b9fa54eb7b
--- /dev/null
+++ b/Lang/SETL/Doomsday-rule
@@ -0,0 +1 @@
+../../Task/Doomsday-rule/SETL
\ No newline at end of file
diff --git a/Lang/SETL/Duffinian-numbers b/Lang/SETL/Duffinian-numbers
new file mode 120000
index 0000000000..93694a20c6
--- /dev/null
+++ b/Lang/SETL/Duffinian-numbers
@@ -0,0 +1 @@
+../../Task/Duffinian-numbers/SETL
\ No newline at end of file
diff --git a/Lang/SETL/Horners-rule-for-polynomial-evaluation b/Lang/SETL/Horners-rule-for-polynomial-evaluation
new file mode 120000
index 0000000000..c30c2e1637
--- /dev/null
+++ b/Lang/SETL/Horners-rule-for-polynomial-evaluation
@@ -0,0 +1 @@
+../../Task/Horners-rule-for-polynomial-evaluation/SETL
\ No newline at end of file
diff --git a/Lang/SETL/Old-lady-swallowed-a-fly b/Lang/SETL/Old-lady-swallowed-a-fly
new file mode 120000
index 0000000000..948ed47605
--- /dev/null
+++ b/Lang/SETL/Old-lady-swallowed-a-fly
@@ -0,0 +1 @@
+../../Task/Old-lady-swallowed-a-fly/SETL
\ No newline at end of file
diff --git a/Lang/SETL/Partition-function-P b/Lang/SETL/Partition-function-P
new file mode 120000
index 0000000000..f47b3bd593
--- /dev/null
+++ b/Lang/SETL/Partition-function-P
@@ -0,0 +1 @@
+../../Task/Partition-function-P/SETL
\ No newline at end of file
diff --git a/Lang/SETL/Square-free-integers b/Lang/SETL/Square-free-integers
new file mode 120000
index 0000000000..328ef78775
--- /dev/null
+++ b/Lang/SETL/Square-free-integers
@@ -0,0 +1 @@
+../../Task/Square-free-integers/SETL
\ No newline at end of file
diff --git a/Lang/Scala/Additive-primes b/Lang/Scala/Additive-primes
new file mode 120000
index 0000000000..ba2692b54f
--- /dev/null
+++ b/Lang/Scala/Additive-primes
@@ -0,0 +1 @@
+../../Task/Additive-primes/Scala
\ No newline at end of file
diff --git a/Lang/Scala/Descending-primes b/Lang/Scala/Descending-primes
new file mode 120000
index 0000000000..461c6bfefd
--- /dev/null
+++ b/Lang/Scala/Descending-primes
@@ -0,0 +1 @@
+../../Task/Descending-primes/Scala
\ No newline at end of file
diff --git a/Lang/Scala/ISBN13-check-digit b/Lang/Scala/ISBN13-check-digit
new file mode 120000
index 0000000000..b0dc1022b2
--- /dev/null
+++ b/Lang/Scala/ISBN13-check-digit
@@ -0,0 +1 @@
+../../Task/ISBN13-check-digit/Scala
\ No newline at end of file
diff --git a/Lang/Scala/Parallel-calculations b/Lang/Scala/Parallel-calculations
new file mode 120000
index 0000000000..525e6ca1ba
--- /dev/null
+++ b/Lang/Scala/Parallel-calculations
@@ -0,0 +1 @@
+../../Task/Parallel-calculations/Scala
\ No newline at end of file
diff --git a/Lang/Sidef/Arithmetic-derivative b/Lang/Sidef/Arithmetic-derivative
new file mode 120000
index 0000000000..bdcd1874e7
--- /dev/null
+++ b/Lang/Sidef/Arithmetic-derivative
@@ -0,0 +1 @@
+../../Task/Arithmetic-derivative/Sidef
\ No newline at end of file
diff --git a/Lang/Sidef/Arithmetic-numbers b/Lang/Sidef/Arithmetic-numbers
new file mode 120000
index 0000000000..672bca881d
--- /dev/null
+++ b/Lang/Sidef/Arithmetic-numbers
@@ -0,0 +1 @@
+../../Task/Arithmetic-numbers/Sidef
\ No newline at end of file
diff --git a/Lang/Sidef/Binary-strings b/Lang/Sidef/Binary-strings
new file mode 120000
index 0000000000..86bf141c80
--- /dev/null
+++ b/Lang/Sidef/Binary-strings
@@ -0,0 +1 @@
+../../Task/Binary-strings/Sidef
\ No newline at end of file
diff --git a/Lang/Sidef/Jordan-P-lya-numbers b/Lang/Sidef/Jordan-P-lya-numbers
new file mode 120000
index 0000000000..b084543da1
--- /dev/null
+++ b/Lang/Sidef/Jordan-P-lya-numbers
@@ -0,0 +1 @@
+../../Task/Jordan-P-lya-numbers/Sidef
\ No newline at end of file
diff --git a/Lang/Sidef/Pell-numbers b/Lang/Sidef/Pell-numbers
new file mode 120000
index 0000000000..af14680327
--- /dev/null
+++ b/Lang/Sidef/Pell-numbers
@@ -0,0 +1 @@
+../../Task/Pell-numbers/Sidef
\ No newline at end of file
diff --git a/Lang/Standard-ML/Knuth-shuffle b/Lang/Standard-ML/Knuth-shuffle
new file mode 120000
index 0000000000..da7fa35b79
--- /dev/null
+++ b/Lang/Standard-ML/Knuth-shuffle
@@ -0,0 +1 @@
+../../Task/Knuth-shuffle/Standard-ML
\ No newline at end of file
diff --git a/Lang/Standard-ML/Pseudo-random-numbers-Splitmix64 b/Lang/Standard-ML/Pseudo-random-numbers-Splitmix64
new file mode 120000
index 0000000000..bce7d31edd
--- /dev/null
+++ b/Lang/Standard-ML/Pseudo-random-numbers-Splitmix64
@@ -0,0 +1 @@
+../../Task/Pseudo-random-numbers-Splitmix64/Standard-ML
\ No newline at end of file
diff --git a/Lang/Standard-ML/URL-encoding b/Lang/Standard-ML/URL-encoding
new file mode 120000
index 0000000000..f4e1b1b4e1
--- /dev/null
+++ b/Lang/Standard-ML/URL-encoding
@@ -0,0 +1 @@
+../../Task/URL-encoding/Standard-ML
\ No newline at end of file
diff --git a/Lang/Stax/00-LANG.txt b/Lang/Stax/00-LANG.txt
index daeb2cc2d2..9436dc0940 100644
--- a/Lang/Stax/00-LANG.txt
+++ b/Lang/Stax/00-LANG.txt
@@ -1 +1,2 @@
-{{stub}}{{language|Stax}}
\ No newline at end of file
+[https://github.com/tomtheisen/stax Github]
+{{language|site=https://staxlang.xyz/}}
\ No newline at end of file
diff --git a/Lang/Swift/M-bius-function b/Lang/Swift/M-bius-function
new file mode 120000
index 0000000000..cd32d72e63
--- /dev/null
+++ b/Lang/Swift/M-bius-function
@@ -0,0 +1 @@
+../../Task/M-bius-function/Swift
\ No newline at end of file
diff --git a/Lang/TI-83-BASIC/00-LANG.txt b/Lang/TI-83-BASIC/00-LANG.txt
index 571b0d2a73..a8830c103d 100644
--- a/Lang/TI-83-BASIC/00-LANG.txt
+++ b/Lang/TI-83-BASIC/00-LANG.txt
@@ -8,24 +8,24 @@
The language contains control flow for structured programming.
The main control flow statements are:
====If====
-#include#include @@ -39,7 +39,7 @@ CONSOLE_APP_MAIN for(int i = 0; i < cmdline.GetCount(); i++) { } } -
#include#include #include @@ -69,7 +69,7 @@ CONSOLE_APP_MAIN for(int i = 0; i < cmdline.GetCount(); i++) { } } -
#include#include #include @@ -108,7 +108,7 @@ CONSOLE_APP_MAIN for(int i = 0; i < cmdline.GetCount(); i++) { } } -
[https://github.com/yaml/yamlscript/releases ys] and is also available in several programming languages as a binding module to the [https://github.com/yaml/yamlscript/releases libyamlscript.so] shared library:
+YS has a compiler/interpreter CLI program called [https://github.com/yaml/yamlscript/releases ys] and is also available in several programming languages as a binding module to the [https://github.com/yaml/yamlscript/releases libyamlscript.so] shared library:
* [https://clojars.org/org.yamlscript/clj-yamlscript Clojure]
* [https://github.com/yaml/yamlscript-go Go]
@@ -21,9 +21,9 @@ YAMLScript has a compiler/interpreter CLI program called [https://github.c
* [https://rubygems.org/gems/yamlscript Ruby]
* [https://crates.io/crates/yamlscript Rust]
-==Installing YAMLScript==
+==Installing YS==
-Run this command to install the ys command line YAMLScript runner/loader/compiler program.
+Run this command to install the ys command line YS runner/loader/compiler binary.
curl -s https://yamlscript.org/install | bash
@@ -34,14 +34,14 @@ That will install $HOME/.local/bin/ys. If $HOME/.local/binnd door (door #2, #4, #6, ...), and toggle it.
+The second time, only visit every 2nd door (door #2, #4, #6, ...), and toggle it.
-The third time, visit every 3rd door (door #3, #6, #9, ...), etc, until you only visit the 100th door.
+The third time, visit every 3rd door (door #3, #6, #9, ...), etc, until you only visit the 100th door.
;Task:
-Answer the question: what state are the doors in after the last pass? Which are open, which are closed?
+Answer the question: what state are the doors in after the last pass? Which are open, which are closed?
'''[[task feature::Rosetta Code:extra credit|Alternate]]:'''
-As noted in this page's [[Talk:100 doors|discussion page]], the only doors that remain open are those whose numbers are perfect squares.
+As noted in this page's [[Talk:100 doors|discussion page]], the only doors that remain open are those whose numbers are perfect squares.
-Opening only those doors is an [[task feature::Rosetta Code:optimization|optimization]] that may also be expressed;
+Opening only those doors is an [[task feature::Rosetta Code:optimization|optimization]] that may also be expressed;
however, as should be obvious, this defeats the intent of comparing implementations across programming languages.
diff --git a/Task/100-doors/8080-Assembly/100-doors.8080 b/Task/100-doors/8080-Assembly/100-doors-1.8080
similarity index 100%
rename from Task/100-doors/8080-Assembly/100-doors.8080
rename to Task/100-doors/8080-Assembly/100-doors-1.8080
diff --git a/Task/100-doors/8080-Assembly/100-doors-2.8080 b/Task/100-doors/8080-Assembly/100-doors-2.8080
new file mode 100644
index 0000000000..48acc304f5
--- /dev/null
+++ b/Task/100-doors/8080-Assembly/100-doors-2.8080
@@ -0,0 +1,92 @@
+ ;------------------------------------------------------
+ ; useful equates
+ ;------------------------------------------------------
+wboot equ 0 ; jump to BIOS warm boot routine
+bdos equ 5 ; BDOS entry
+conout equ 2 ; BDOS console output function
+putstr equ 9 ; BDOS print string function
+ndoors equ 100
+ ;
+ org 100h
+ lxi sp,stack ; set our own stack
+ lxi d,signon ; print signon message
+ mvi c,putstr
+ call bdos
+ ;
+ ; generate sequence of squares from 1 to specified limit
+ ;
+gensqr:
+ lxi h,1 ; starting value of square
+ lxi d,3 ; starting value of increment
+ lxi b,ndoors+1
+sqrs2:
+ call cmpbchl ; have we exceeded the limit?
+ jnc done ; we're finished
+ call putdec ; otherwise print current square
+ mvi a,' ' ; separate with a space
+ call putchr
+ dad d ; square += incrememnt
+ inx d ; increment += 2
+ inx d
+ jmp sqrs2 ; repeat until finished
+ ;
+done: jmp wboot ; exit to command prompt
+ ;
+ ;---------------------------------------------------
+ ; 16-bit unsigned comparison of HL and BC
+ ; if HL = BC then Z flag set
+ ; if HL < BC then CY flag set (NC if HL >= BC)
+ ;------------------------------------------------------
+cmpbchl:
+ mov a,h
+ cmp b
+ rnz
+ mov a,l
+ cmp c
+ ret
+ ;---------------------------------------------------
+ ; console output of char in A register
+ ;---------------------------------------------------
+putchr: push h
+ push d
+ push b
+ mov e,a
+ mvi c,conout
+ call bdos
+ pop b
+ pop d
+ pop h
+ ret
+ ;---------------------------------------------------
+ ; Output decimal number to console
+ ; HL holds 16-bit unsigned binary number to print
+ ;---------------------------------------------------
+putdec: push b
+ push d
+ push h
+ lxi b,-10
+ lxi d,-1
+putdec2:
+ dad b
+ inx d
+ jc putdec2
+ lxi b,10
+ dad b
+ xchg
+ mov a,h
+ ora l
+ cnz putdec ; recursive call
+ mov a,e
+ adi '0'
+ call putchr
+ pop h
+ pop d
+ pop b
+ ret
+ ;---------------------------------------------------
+ ; data area and stack
+ ;---------------------------------------------------
+signon: db 'The open doors are: $'
+stack equ $+128 ; 64-level stack
+ ;
+ end
diff --git a/Task/100-doors/C-sharp/100-doors-1.cs b/Task/100-doors/C-sharp/100-doors-1.cs
index d06413f95c..3e031cc721 100644
--- a/Task/100-doors/C-sharp/100-doors-1.cs
+++ b/Task/100-doors/C-sharp/100-doors-1.cs
@@ -5,11 +5,10 @@ namespace ConsoleApplication1
{
static void Main(string[] args)
{
+ // Arrays are initialized to their type default values; the default for bool is false
+ // Use false to indicate closed door
bool[] doors = new bool[100];
- //Close all doors to start.
- for (int d = 0; d < 100; d++) doors[d] = false;
-
//For each pass...
for (int p = 0; p < 100; p++)//number of passes
{
@@ -24,7 +23,7 @@ namespace ConsoleApplication1
}
//Output the results.
- Console.WriteLine("Passes Completed!!! Here are the results: \r\n");
+ Console.WriteLine("Passes Completed!!! Here are the results:");
for (int d = 0; d < 100; d++)
{
if (doors[d])
diff --git a/Task/100-doors/C/100-doors-3.c b/Task/100-doors/C/100-doors-3.c
index fb7f7feb29..d8fed2c66e 100644
--- a/Task/100-doors/C/100-doors-3.c
+++ b/Task/100-doors/C/100-doors-3.c
@@ -1,19 +1,14 @@
#include
+#include
-int main()
-{
- int square = 1, increment = 3, door;
- for (door = 1; door <= 100; ++door)
- {
- printf("door #%d", door);
- if (door == square)
- {
- printf(" is open.\n");
- square += increment;
- increment += 2;
- }
- else
- printf(" is closed.\n");
- }
- return 0;
+int main() {
+ uint32_t doorBytes[4] = {0};
+
+ for (uint32_t i = 1; i <= 100; ++i)
+ for (uint32_t j = i - 1; j <= 99; j += i)
+ doorBytes[j % 4] ^= (uint32_t)1 << j / 4;
+
+ for (uint32_t i = 0; i <= 99; doorBytes[i++ % 4] >>= 1)
+ if (doorBytes[i % 4] & 1)
+ printf("door %d is open\n", i + 1);
}
diff --git a/Task/100-doors/C/100-doors-4.c b/Task/100-doors/C/100-doors-4.c
index a1972a382b..fb7f7feb29 100644
--- a/Task/100-doors/C/100-doors-4.c
+++ b/Task/100-doors/C/100-doors-4.c
@@ -2,8 +2,18 @@
int main()
{
- int door, square, increment;
- for (door = 1, square = 1, increment = 1; door <= 100; door++ == square && (square += increment += 2))
- printf("door #%d is %s.\n", door, (door == square? "open" : "closed"));
+ int square = 1, increment = 3, door;
+ for (door = 1; door <= 100; ++door)
+ {
+ printf("door #%d", door);
+ if (door == square)
+ {
+ printf(" is open.\n");
+ square += increment;
+ increment += 2;
+ }
+ else
+ printf(" is closed.\n");
+ }
return 0;
}
diff --git a/Task/100-doors/C/100-doors-5.c b/Task/100-doors/C/100-doors-5.c
index 4988099e36..a1972a382b 100644
--- a/Task/100-doors/C/100-doors-5.c
+++ b/Task/100-doors/C/100-doors-5.c
@@ -2,9 +2,8 @@
int main()
{
- int i;
- for (i = 1; i * i <= 100; i++)
- printf("door %d open\n", i * i);
-
- return 0;
+ int door, square, increment;
+ for (door = 1, square = 1, increment = 1; door <= 100; door++ == square && (square += increment += 2))
+ printf("door #%d is %s.\n", door, (door == square? "open" : "closed"));
+ return 0;
}
diff --git a/Task/100-doors/C/100-doors-6.c b/Task/100-doors/C/100-doors-6.c
new file mode 100644
index 0000000000..4988099e36
--- /dev/null
+++ b/Task/100-doors/C/100-doors-6.c
@@ -0,0 +1,10 @@
+#include
+
+int main()
+{
+ int i;
+ for (i = 1; i * i <= 100; i++)
+ printf("door %d open\n", i * i);
+
+ return 0;
+}
diff --git a/Task/100-doors/Emacs-Lisp/100-doors.l b/Task/100-doors/Emacs-Lisp/100-doors-1.l
similarity index 100%
rename from Task/100-doors/Emacs-Lisp/100-doors.l
rename to Task/100-doors/Emacs-Lisp/100-doors-1.l
diff --git a/Task/100-doors/Emacs-Lisp/100-doors-2.l b/Task/100-doors/Emacs-Lisp/100-doors-2.l
new file mode 100644
index 0000000000..66b2cff437
--- /dev/null
+++ b/Task/100-doors/Emacs-Lisp/100-doors-2.l
@@ -0,0 +1,16 @@
+(defun one-hundred-doors(initial-state)
+ "Turn doors in INITIAL-STATE according to 100 Doors problem."
+ (interactive "nEnter initial doors' state (as a number): ")
+ (cl-loop for x from 1 to 100
+ do (cl-loop for y from (1- x) to 99 by x
+ do (setq initial-state (logxor initial-state (ash 1 y)))))
+ (let ((counter 1)
+ (open-doors nil))
+ (while (> initial-state 0)
+ (when (eq (mod initial-state 2) 1)
+ (push counter open-doors))
+ (cl-incf counter)
+ (setq initial-state (/ initial-state 2)))
+ (message "Open doors are %s" (reverse open-doors))))
+
+(one-hundred-doors 0)
diff --git a/Task/100-doors/Langur/100-doors-2.langur b/Task/100-doors/Langur/100-doors-2.langur
index f0f96dadfb..9fbe548626 100644
--- a/Task/100-doors/Langur/100-doors-2.langur
+++ b/Task/100-doors/Langur/100-doors-2.langur
@@ -1 +1 @@
-writeln foldfrom(fn a, b, c: if(b: a~[c]; a), [], doors, series(1..len(doors)))
+writeln fold(doors, series(1..len(doors)), by=fn a, b, c: if(b: a~[c]; a), init=[])
diff --git a/Task/100-doors/Langur/100-doors-3.langur b/Task/100-doors/Langur/100-doors-3.langur
index 67108b6065..61d90f3fb8 100644
--- a/Task/100-doors/Langur/100-doors-3.langur
+++ b/Task/100-doors/Langur/100-doors-3.langur
@@ -1 +1 @@
-writeln map(fn{^2}, 1..10)
+writeln map(1..10, by=fn{^2})
diff --git a/Task/100-doors/Plain-English/100-doors.plain b/Task/100-doors/Plain-English/100-doors.plain
index 056c6f1ec1..2ebc38ce0b 100644
--- a/Task/100-doors/Plain-English/100-doors.plain
+++ b/Task/100-doors/Plain-English/100-doors.plain
@@ -1,14 +1,31 @@
+A flag list is a doubly linked list with a flag.
+A door is a flag list.
+A pass is a number.
+
+To run:
+ Start up.
+ Pass doors given 1000 and 1000 passes.
+ Shut down.
+
+To pass doors given a count and some passes:
+ Create some doors given the count.
+ Loop.
+ Add 1 to a counter.
+ If the counter is greater than the passes, break.
+ Go through the doors given the counter and the passes.
+ Repeat.
+ Output the states of the doors.
+ Destroy the doors.
+
To create some doors given a count:
Loop.
- If a counter is past the count, exit.
+ Add 1 to a counter.
+ If the counter is greater than the count, exit.
Allocate memory for a door.
Clear the door's flag.
Append the door to the doors.
Repeat.
-A flag thing is a thing with a flag.
-A door is a flag thing.
-
To go through some doors given a number and some passes:
Put 0 into a counter.
Loop.
@@ -18,37 +35,23 @@ To go through some doors given a number and some passes:
Invert the door's flag.
Repeat.
+To pick a door from some doors given a number:
+ Loop.
+ Add 1 to a counter.
+ If the counter is greater than the number, exit.
+ Get the door from the doors.
+ If the door is nil, exit.
+ Repeat.
+
To output the states of some doors:
Loop.
Bump a counter.
Get a door from the doors.
If the door is nil, exit.
If the door's flag is set,
- Write "Door " then the counter then " is open" to the output;
+ Write "Door " then the counter then " is open"
+ then the CRLF string to StdOut;
Repeat.
- Write "Door " then the counter then " is closed" to the output.
+ \Write "Door " then the counter then " is closed"
+ \then the CRLF string to StdOut.
Repeat.
-
-To pass doors given a count and some passes:
- Create some doors given the count.
- Loop.
- If a counter is past the passes, break.
- Go through the doors given the counter and the passes.
- Repeat.
- Output the states of the doors.
- Destroy the doors.
-
-A pass is a number.
-
-To pick a door from some doors given a number:
- Loop.
- If a counter is past the number, exit.
- Get the door from the doors.
- If the door is nil, exit.
- Repeat.
-
-To run:
- Start up.
- Pass doors given 100 and 100 passes.
- Wait for the escape key.
- Shut down.
diff --git a/Task/100-doors/V-(Vlang)/100-doors-3.v b/Task/100-doors/V-(Vlang)/100-doors-3.v
index bce04b6c59..8f720ebff3 100644
--- a/Task/100-doors/V-(Vlang)/100-doors-3.v
+++ b/Task/100-doors/V-(Vlang)/100-doors-3.v
@@ -1,5 +1,11 @@
+import math
+
+const number_doors = 101
+
fn main() {
- for i in 1..11 {
- print ( " Door ${i*i} is open.\n" )
- }
+ max_i := int(math.sqrt(f64(number_doors - 1))) + 1
+ for i in 1..max_i {
+ door := i * i
+ println("Door ${door} open")
+ }
}
diff --git a/Task/100-doors/V-(Vlang)/100-doors-4.v b/Task/100-doors/V-(Vlang)/100-doors-4.v
new file mode 100644
index 0000000000..bce04b6c59
--- /dev/null
+++ b/Task/100-doors/V-(Vlang)/100-doors-4.v
@@ -0,0 +1,5 @@
+fn main() {
+ for i in 1..11 {
+ print ( " Door ${i*i} is open.\n" )
+ }
+}
diff --git a/Task/100-doors/YAMLScript/100-doors.ys b/Task/100-doors/YAMLScript/100-doors.ys
index 23c45269c2..7e63c2a67d 100644
--- a/Task/100-doors/YAMLScript/100-doors.ys
+++ b/Task/100-doors/YAMLScript/100-doors.ys
@@ -1,4 +1,4 @@
-!yamlscript/v0
+!YS-v0
defn main():
open =:
diff --git a/Task/100-doors/Zig/100-doors-4.zig b/Task/100-doors/Zig/100-doors-4.zig
index 53b792a533..14d911f591 100644
--- a/Task/100-doors/Zig/100-doors-4.zig
+++ b/Task/100-doors/Zig/100-doors-4.zig
@@ -1,8 +1,7 @@
pub fn main() !void {
const stdout = @import("std").io.getStdOut().writer();
- var door: u8 = 1;
- while (door * door <= 100) : (door += 1) {
+ for(1..11) |door| {
try stdout.print("Door {d} is open\n", .{door * door});
}
}
diff --git a/Task/100-prisoners/ALGOL-68/100-prisoners.alg b/Task/100-prisoners/ALGOL-68/100-prisoners.alg
new file mode 100644
index 0000000000..e8858ff506
--- /dev/null
+++ b/Task/100-prisoners/ALGOL-68/100-prisoners.alg
@@ -0,0 +1,66 @@
+BEGIN # 100 prisoners #
+
+CO begin code from the Knuth shuffle task CO
+PROC between = (INT a, b)INT :
+(
+ ENTIER (random * ABS (b-a+1) + (a 0 THEN r = z - 1
+ CASE 4: IF z MOD 4 <> 0 THEN r = z + 1
+ END SELECT
+ LOOP WHILE (r < 1) OR (r > 16)
+ d(z) = d(r)
+ z = r
+ d(z) = 0
+ NEXT n
+ CLS
+END SUB
+
+FUNCTION introAndLevel
+ CLS
+ sh(1) = 10
+ sh(2) = 50
+ sh(3) = 100
+ PRINT "15 PUZZLE GAME": PRINT: PRINT
+ PRINT "Please enter level of difficulty,"
+ DO
+ PRINT "1 (easy), 2 (medium) or 3 (hard): ";
+ INPUT level
+ LOOP WHILE (level < 1) OR (level > 3)
+ introAndLevel = level
+END FUNCTION
+
+FUNCTION isMoveValid (piece AS INTEGER, piecePos AS INTEGER, emptyPos AS INTEGER)
+ mv = 0
+ IF (piece >= 1) AND (piece <= 15) THEN
+ piecePos = piecePosition(piece)
+ emptyPos = piecePosition(0)
+ IF (piecePos - 4 = emptyPos) OR (piecePos + 4 = emptyPos) OR ((piecePos - 1 = emptyPos) AND (emptyPos MOD 4 <> 0)) OR ((piecePos + 1 = emptyPos) AND (piecePos MOD 4 <> 0)) THEN
+ mv = 1
+ END IF
+ END IF
+ isMoveValid = mv
+END FUNCTION
+
+FUNCTION isPuzzleComplete
+ pc = 0
+ p = 1
+ WHILE (p < 16) AND (d(p) = p)
+ p = p + 1
+ WEND
+ IF p = 16 THEN pc = 1
+ isPuzzleComplete = pc
+END FUNCTION
+
+FUNCTION piecePosition (piece AS INTEGER)
+ p = 1
+ WHILE d(p) <> piece
+ p = p + 1
+ IF p > 16 THEN
+ PRINT "UH OH!"
+ STOP
+ END IF
+ WEND
+ piecePosition = p
+END FUNCTION
+
+SUB printPuzzle
+ FOR p = 1 TO 16
+ IF d(p) = 0 THEN
+ dbp$(p) = " "
+ ELSE
+ dbp$(p) = RIGHT$(" " + LTRIM$(STR$(d(p))), 3) + " "
+ END IF
+ NEXT p
+
+ PRINT "+-----+-----+-----+-----+"
+ PRINT "|"; dbp$(1); "|"; dbp$(2); "|"; dbp$(3); "|"; dbp$(4); "|"
+ PRINT "+-----+-----+-----+-----+"
+ PRINT "|"; dbp$(5); "|"; dbp$(6); "|"; dbp$(7); "|"; dbp$(8); "|"
+ PRINT "+-----+-----+-----+-----+"
+ PRINT "|"; dbp$(9); "|"; dbp$(10); "|"; dbp$(11); "|"; dbp$(12); "|"
+ PRINT "+-----+-----+-----+-----+"
+ PRINT "|"; dbp$(13); "|"; dbp$(14); "|"; dbp$(15); "|"; dbp$(16); "|"
+ PRINT "+-----+-----+-----+-----+"
+END SUB
diff --git a/Task/2048/Guile/2048.guile b/Task/2048/Guile/2048.guile
new file mode 100644
index 0000000000..f8b103f0d4
--- /dev/null
+++ b/Task/2048/Guile/2048.guile
@@ -0,0 +1,312 @@
+;;require-module (ice-9 format)
+;;usage -> [~4d] print-board
+;;
+(use-modules (ice-9 format))
+
+;;require-module (srfi srfi-64)
+;;usage -> test-assert
+;;
+(use-modules (srfi srfi-64))
+
+;;prodedure-name 2or4-generator
+;;input -> <$:nil>
+;;output -> _ (number)
+;;note -> "it only generates 2 or 4, with a 10% of outputting 4"
+;;
+(define 2or4-generator
+ (lambda ()
+ (let ([random-number (random 10)])
+ (if (zero? random-number)
+ 4
+ 2))))
+
+;;procedure-name print-board
+;;input -> board (array::4*4)
+;;output -> <$:nil>
+;;
+(define print-board
+ (lambda (board)
+ (do ((i 0 (1+ i)))
+ ((> i 3))
+ (do ((j 0 (1+ j)))
+ ((> j 3))
+ (format #t "[~4d]" (array-ref board i j)))
+ (newline))))
+
+;;procedure-name spawn!
+;;input -> 4x4board (array::4*4)
+;;output -> <$:nil>
+;;
+(define spawn!
+ (lambda (4x4board)
+ (let ([indexes '()])
+ (do ((i 0 (1+ i)))
+ ((> i 3))
+ (do ((j 0 (1+ j)))
+ ((> j 3))
+ (when (zero? (array-ref 4x4board i j))
+ (set! indexes (cons (cons i j) indexes)))))
+ (let* ([indexes-length (length indexes)]
+ [used-index-index (random indexes-length)]
+ [used-index-pair (list-ref indexes used-index-index)])
+ (array-set! 4x4board (2or4-generator) (car used-index-pair) (cdr used-index-pair))))))
+
+;;procedure-name ask-user
+;;input -> valid-moves (list:symbol)
+;;output -> _ (symbol) [(memq <$:self:_> (list 'up 'down 'left 'right)) => #t]
+;;note -> "this procedure assumes there is at least one valid move"
+;;
+(define ask-user
+ (lambda (valid-moves)
+ (let loop ()
+ (let ([option (read)])
+ (if (memq option valid-moves)
+ (case option
+ [(up) 'up]
+ [(down) 'down]
+ [(left) 'left]
+ [(right) 'right]
+ [else (begin
+ (display "wrong input! Please type up, down, left, or right only!")
+ (newline)
+ (loop))])
+ (begin
+ (display "please use valid moves!")
+ (newline)
+ (display "valid moves: ")
+ (display valid-moves)
+ (newline)
+ (loop)))))))
+
+;;procedure-name update-row!
+;;input -> row (array::1*4)
+;;output -> <$:nil>
+;;
+(define update-row!
+ (lambda (row)
+ (unless (array-equal? row #(0 0 0 0))
+ (let ([lst '()] [l 0])
+ (when (not (zero? (array-ref row 3))) (set! l (1+ l)) (set! lst (cons (array-ref row 3) lst)))
+ (when (not (zero? (array-ref row 2))) (set! l (1+ l)) (set! lst (cons (array-ref row 2) lst)))
+ (when (not (zero? (array-ref row 1))) (set! l (1+ l)) (set! lst (cons (array-ref row 1) lst)))
+ (when (not (zero? (array-ref row 0))) (set! l (1+ l)) (set! lst (cons (array-ref row 0) lst)))
+ (do ((i 0 (1+ i)))
+ ((>= i (- 4 l)))
+ (array-set! row 0 i))
+ (do ((i (- 4 l) (1+ i)) (j 0 (1+ j)))
+ ((>= i 4))
+ (array-set! row (list-ref lst j) i)))
+ (if (= (array-ref row 3) (array-ref row 2))
+ (begin (array-set! row (+ (array-ref row 3) (array-ref row 2)) 3)
+ (array-set! row (array-ref row 1) 2)
+ (array-set! row (array-ref row 0) 1)
+ (array-set! row 0 0)
+ (when (= (array-ref row 2) (array-ref row 1))
+ (array-set! row (+ (array-ref row 2) (array-ref row 1)) 2)
+ (array-set! row 0 1)))
+ (if (= (array-ref row 2) (array-ref row 1))
+ (begin (array-set! row (+ (array-ref row 2) (array-ref row 1)) 2)
+ (array-set! row (array-ref row 0) 1)
+ (array-set! row 0 0))
+ (when (= (array-ref row 1) (array-ref row 0))
+ (array-set! row (+ (array-ref row 1) (array-ref row 0)) 1)
+ (array-set! row 0 0)))))))
+
+;;procedure-name update-board!
+;;input -> board (array::4*4)
+;;output -> <$:nil>
+;;note -> "this procedure can assume that the opertion is shifting the piles right"
+;;
+(define update-board!
+ (lambda (board)
+ (do ((i 0 (1+ i)))
+ ((>= i 4))
+ (update-row! (array-cell-ref board i)))))
+
+;;procedure-name row-can-shift-qright?
+;;input -> row (array::1*4)
+;;output -> _ (#t or #f)
+;;
+(define row-can-shift-right?
+ (lambda (row)
+ (if (and (zero? (array-ref row 0))
+ (zero? (array-ref row 1))
+ (zero? (array-ref row 2)))
+ #f
+ (if (or (zero? (array-ref row 3))
+ (and (not (zero? (array-ref row 0))) (member 0 (list
+ (array-ref row 1)
+ (array-ref row 2)
+ (array-ref row 3))))
+ (and (not (zero? (array-ref row 1))) (member 0 (list
+ (array-ref row 2)
+ (array-ref row 3))))
+ (and (not (zero? (array-ref row 2))) (member 0 (list
+ (array-ref row 3)))))
+ #t
+ (if (or (and (not (zero? (array-ref row 0))) (= (array-ref row 0) (array-ref row 1)))
+ (and (not (zero? (array-ref row 1))) (= (array-ref row 1) (array-ref row 2)))
+ (and (not (zero? (array-ref row 2))) (= (array-ref row 2) (array-ref row 3))))
+ #t
+ #f)))))
+
+(define test-row-can-shift-right?
+ (lambda ()
+ (test-begin "row-can-shift-right? test")
+ (test-assert (row-can-shift-right? #(2 0 0 0)))
+ (test-assert (row-can-shift-right? #(0 2 0 0)))
+ (test-assert (row-can-shift-right? #(0 0 2 0)))
+ (test-assert (not (row-can-shift-right? #(0 0 0 2))))
+ (test-assert (row-can-shift-right? #(4 2 0 0)))
+ (test-assert (row-can-shift-right? #(2 0 0 2)))
+ (test-assert (row-can-shift-right? #(1024 8 2 2)))
+ (test-end "row-can-shift-right? test")))
+
+;;procedure-name can-shift-right?
+;;input -> board (array::4*4)
+;;output -> _ (#t or #f)
+;;
+(define can-shift-right?
+ (lambda (board)
+ (or (row-can-shift-right? (array-cell-ref board 0))
+ (row-can-shift-right? (array-cell-ref board 1))
+ (row-can-shift-right? (array-cell-ref board 2))
+ (row-can-shift-right? (array-cell-ref board 3)))))
+
+(define test-can-shift-right?
+ (lambda ()
+ (test-begin "can-shift-right? test")
+ (test-assert (can-shift-right? #2((2 0 0 2)
+ (0 0 0 0)
+ (0 0 0 0)
+ (0 0 0 0))))
+ (test-assert (can-shift-right? #2((2 0 0 0)
+ (0 0 0 0)
+ (0 0 0 0)
+ (2 0 0 0))))
+ (test-assert (not (can-shift-right? #2((2 8 4 8)
+ (2 16 4 8)
+ (0 0 0 4)
+ (0 0 0 2)))))
+ (test-end "can-shift-right? test")))
+
+;;procedure-name valid-move?
+;;input -> board (array::4*4)
+;;output -> _ (symbol) [(eq? 'gameover <$:self:_>) => #t]
+;;output -> _ (list:symbol[1 or 2 or 3 or 4])
+;;note -> "the list symbol should only contain up, down, left, right"
+;;
+(define valid-move?
+ (lambda (board)
+ (let* ([output-lst '()]
+ [rows board]
+ [columns (make-shared-array rows
+ (lambda (i j)
+ (list j i))
+ 4 4)]
+ [rows-reversed (make-shared-array rows
+ (lambda (i j)
+ (list i (- 3 j)))
+ 4 4)]
+ [columns-reversed (make-shared-array columns
+ (lambda (i j)
+ (list i (- 3 j)))
+ 4 4)])
+ (when (can-shift-right? rows) (set! output-lst (append (list 'right) output-lst)))
+ (when (can-shift-right? rows-reversed) (set! output-lst (append (list 'left) output-lst)))
+ (when (can-shift-right? columns) (set! output-lst (append (list 'down) output-lst)))
+ (when (can-shift-right? columns-reversed) (set! output-lst (append (list 'up) output-lst)))
+ (if (null? output-lst)
+ 'gameover
+ output-lst))))
+
+(define test-valid-move?
+ (lambda ()
+ (test-begin "valid-move? test")
+ (test-assert (eq? 'gameover (valid-move? #2((8 4 2 16)
+ (2 8 4 32)
+ (4 2 8 16)
+ (128 4 16 64)))))
+ (test-assert (equal? (list 'up 'down 'left 'right) (valid-move? #2((0 0 0 0)
+ (0 2 0 0)
+ (0 0 0 0)
+ (0 0 0 2)))))
+ (test-end "valid-move? test")))
+
+;;prodedure-name check-game-status!
+;;input -> board (array::4*4)
+;;output -> _ (symbol)
+;;note -> "The thing this procedure should implement: 1.decide whether there is a 2048 tile on board, if so, return 'win 2.decide the valid moves next time and return them as a list like (list 'up 'down 'right) or anything equivalent (if there is no valid moves, just return 'gameover)"
+;;
+(define check-game-status!
+ (lambda (board)
+ (spawn! board)
+ (let ([all-tiles (list (array-ref board 0 0)
+ (array-ref board 0 1)
+ (array-ref board 0 2)
+ (array-ref board 0 3)
+ (array-ref board 1 0)
+ (array-ref board 1 1)
+ (array-ref board 1 2)
+ (array-ref board 1 3)
+ (array-ref board 2 0)
+ (array-ref board 2 1)
+ (array-ref board 2 2)
+ (array-ref board 2 3)
+ (array-ref board 3 0)
+ (array-ref board 3 1)
+ (array-ref board 3 2)
+ (array-ref board 3 3))])
+ (if (member 2048 all-tiles)
+ 'win
+ (valid-move? board)))))
+
+;;procedure-name play
+;;input -> <$:nil>
+;;output -> _ (array:4*4)
+;;
+(define play
+ (lambda ()
+ (set! *random-state* (random-state-from-platform))
+ (let ([board (make-array 0 4 4)])
+ (let* ([rows board]
+ [columns (make-shared-array rows
+ (lambda (i j)
+ (list j i))
+ 4 4)]
+ [rows-reversed (make-shared-array rows
+ (lambda (i j)
+ (list i (- 3 j)))
+ 4 4)]
+ [columns-reversed (make-shared-array columns
+ (lambda (i j)
+ (list i (- 3 j)))
+ 4 4)])
+ (spawn! rows)
+ (let loop ([turn 1] [available-moves (valid-move? rows)])
+ (format #t "TURN ~d" turn)
+ (newline)
+ (print-board rows)
+ (case (ask-user available-moves)
+ [(up) (update-board! columns-reversed)]
+ [(down) (update-board! columns)]
+ [(left) (update-board! rows-reversed)]
+ [(right) (update-board! rows)]
+ [else (error "something went wrong! The return stuff from (ask-user availuable-moves) is not among 'up 'down 'left 'right! This normally should never be reached.")])
+ (let ([symbols (check-game-status! rows)])
+ (cond
+ [(symbol? symbols) (case symbols
+ [(win) (begin
+ (display "You win!")
+ (newline)
+ (print-board rows))]
+ [(gameover) (begin
+ (display "You lose!")
+ (newline)
+ (print-board rows))]
+ [else (error "While not intended, we named what the procedure (check-game-status rows) returned as symbols, checking it as a symbol which passed, then we get this. But we coded this to be 'win or 'gameover !")])]
+ [(list? symbols) (begin
+ (display "Valid moves: ")
+ (display symbols)
+ (newline)
+ (loop (1+ turn) symbols))])))))))
diff --git a/Task/24-game-Solve/FreeBASIC/24-game-solve.basic b/Task/24-game-Solve/FreeBASIC/24-game-solve.basic
new file mode 100644
index 0000000000..4593f64cb2
--- /dev/null
+++ b/Task/24-game-Solve/FreeBASIC/24-game-solve.basic
@@ -0,0 +1,124 @@
+Type GameState
+ digitos(3) As Double
+ operaciones(2) As String
+End Type
+
+Function randomDigits() As String
+ Dim As String resultado = ""
+ For i As Integer = 0 To 3
+ resultado &= Str(Int(Rnd * 9) + 1)
+ Next
+ Return resultado
+End Function
+
+Function evaluate(digitos() As Double, operaciones() As String) As Double
+ Dim As Double valor = digitos(0)
+
+ For i As Integer = 0 To 2
+ Select Case operaciones(i)
+ Case "+": valor += digitos(i +1)
+ Case "-": valor -= digitos(i +1)
+ Case "*": valor *= digitos(i +1)
+ Case "/": If digitos(i +1) <> 0 Then valor /= digitos(i +1)
+ End Select
+ Next
+
+ Return valor
+End Function
+
+Sub permute(digitos() As Double, soluciones() As GameState, Byref solutionCnt As Integer, k As Integer)
+ Dim As String*1 opChars(3) = {"+", "-", "*", "/"}
+ Dim As String ops(2)
+ Dim As Integer i, j, l, m
+
+ If k = 4 Then
+ For i = 0 To 3
+ ops(0) = opChars(i)
+ For j = 0 To 3
+ ops(1) = opChars(j)
+ For l = 0 To 3
+ ops(2) = opChars(l)
+ If Abs(evaluate(digitos(), ops()) - 24) < 0.001 Then
+ With soluciones(solutionCnt)
+ For m = 0 To 3: .digitos(m) = digitos(m): Next
+ For m = 0 To 2: .operaciones(m) = ops(m): Next
+ End With
+ solutionCnt += 1
+ Exit For 'Stop after first solution
+ End If
+ Next
+ If solutionCnt Then Exit For
+ Next
+ If solutionCnt Then Exit For
+ Next
+ Else
+ For i = k To 3
+ Swap digitos(i), digitos(k)
+ permute(digitos(), soluciones(), solutionCnt, k +1)
+ If solutionCnt Then Exit For
+ Swap digitos(k), digitos(i)
+ Next
+ End If
+End Sub
+
+' Main program
+Randomize Timer
+Dim As Integer i
+Dim As String cmd
+Dim As Double digitos(3)
+Dim As String operaciones(2)
+
+Do
+ Cls
+ Print "24 Game"
+ Print "Generating 4 digitos..."
+
+ Dim As String inputDigits = randomDigits()
+ Print "Make 24 using these digitos: ";
+ For i = 1 To Len(inputDigits)
+ Print Mid(inputDigits, i, 1); " ";
+ Next
+ Print
+
+ Line Input "Enter your expression (e.g. 4+5*3-2): ", cmd
+
+ Dim As Integer digitCnt = 0, opCnt = 0
+ ' Parse user input
+ For i = 1 To Len(cmd)
+ Select Case Mid(cmd, i, 1)
+ Case "1" To "9"
+ digitos(digitCnt) = Val(Mid(cmd, i, 1))
+ digitCnt += 1
+ Case "+", "-", "*", "/"
+ operaciones(opCnt) = Mid(cmd, i, 1)
+ opCnt += 1
+ End Select
+ Next
+
+ Dim As Double resultado = evaluate(digitos(), operaciones())
+ Print "Your resultado: "; resultado
+
+ If Abs(resultado - 24) < 0.001 Then
+ Print !"\nCongratulations, you found a solution!"
+ Else
+ Print !"\nThe valor of your expression is "; resultado; " instead of 24!"
+
+ Dim As GameState soluciones(1000)
+ Dim As Integer solucCnt = 0
+
+ permute(digitos(), soluciones(), solucCnt, 0)
+
+ If solucCnt > 0 Then
+ Print !"\nA possible solution could have been: ";
+ With soluciones(0)
+ Print .digitos(0) & .operaciones(0) & .digitos(1) & .operaciones(1) & .digitos(2) & .operaciones(2) & .digitos(3)
+ End With
+ Else
+ Print !"\nThere was no known solution for these digitos."
+ End If
+ End If
+
+ Print !"\nDo you want to try again? (press N for exit, other key to continue)"
+Loop Until (Ucase(Input(1)) = "N")
+
+Sleep
diff --git a/Task/24-game/EasyLang/24-game.easy b/Task/24-game/EasyLang/24-game.easy
index aa12c02486..812e03f085 100644
--- a/Task/24-game/EasyLang/24-game.easy
+++ b/Task/24-game/EasyLang/24-game.easy
@@ -1,6 +1,5 @@
-print "Enter an equation in RPN form using all of, and"
-print "only the following single digits which evaluates"
-print "to 24. Only '*', '/', '+' and '-' are allowed:"
+print "Enter an equation in RPN form using all of, and only "
+print "the following single digits which evaluates to 24:"
func game .
len cnt[] 9
write ">> "
diff --git a/Task/24-game/J/24-game.j b/Task/24-game/J/24-game.j
index 73034a24eb..928663b455 100644
--- a/Task/24-game/J/24-game.j
+++ b/Task/24-game/J/24-game.j
@@ -1,6 +1,6 @@
require'misc'
-deal=: 1 + ? bind 9 9 9 9
-rules=: smoutput bind 'see http://en.wikipedia.org/wiki/24_Game'
+deal=: 1 + ? @ 9 9 9 9
+rules=: echo @ 'see http://en.wikipedia.org/wiki/24_Game'
input=: prompt @ ('enter 24 expression using ', ":, ': '"_)
wellformed=: (' '<;._1@, ":@[) -:&(/:~) '(+-*%)' -.&;:~ ]
diff --git a/Task/4-rings-or-4-squares-puzzle/Quackery/4-rings-or-4-squares-puzzle.quackery b/Task/4-rings-or-4-squares-puzzle/Quackery/4-rings-or-4-squares-puzzle.quackery
new file mode 100644
index 0000000000..fd5fa00757
--- /dev/null
+++ b/Task/4-rings-or-4-squares-puzzle/Quackery/4-rings-or-4-squares-puzzle.quackery
@@ -0,0 +1,36 @@
+ [ swap dip [ 1+ split drop ]
+ split nip ] is slice ( [ n n --> [ )
+
+ [ 0 swap witheach + ] is sum ( [ --> n )
+
+ [ slice sum join ] is square ( [ [ n n --> [ )
+
+ [ true swap
+ behead swap witheach
+ [ over = not if
+ [ dip not conclude ] ]
+ drop ] is same ( [ --> b )
+
+ [ [] temp put
+ over - 1+ times
+ [ dup i^ + temp gather ]
+ drop
+ temp take ] is low->high ( n n --> [ )
+
+ [ [] temp put
+ witheach
+ [ []
+ over 0 1 square
+ over 1 3 square
+ over 3 5 square
+ over 5 6 square
+ same iff
+ [ nested temp gather ]
+ else drop ]
+ temp take ] is task ( [ n --> [ )
+
+ 1 7 low->high permutations task
+ witheach [ echo cr ] cr
+ 3 9 low->high permutations task
+ witheach [ echo cr ] cr
+ 0 9 low->high 7 arrangements task size echo
diff --git a/Task/99-bottles-of-beer/Dart/99-bottles-of-beer.dart b/Task/99-bottles-of-beer/Dart/99-bottles-of-beer.dart
index 3251bd7375..07a966aa75 100644
--- a/Task/99-bottles-of-beer/Dart/99-bottles-of-beer.dart
+++ b/Task/99-bottles-of-beer/Dart/99-bottles-of-beer.dart
@@ -57,5 +57,3 @@ class BeerSong extends Song {
return theLyrics;
}
}
-
-}
diff --git a/Task/99-bottles-of-beer/Elixir/99-bottles-of-beer.ex b/Task/99-bottles-of-beer/Elixir/99-bottles-of-beer-1.ex
similarity index 100%
rename from Task/99-bottles-of-beer/Elixir/99-bottles-of-beer.ex
rename to Task/99-bottles-of-beer/Elixir/99-bottles-of-beer-1.ex
diff --git a/Task/99-bottles-of-beer/Elixir/99-bottles-of-beer-2.ex b/Task/99-bottles-of-beer/Elixir/99-bottles-of-beer-2.ex
new file mode 100644
index 0000000000..21f101524c
--- /dev/null
+++ b/Task/99-bottles-of-beer/Elixir/99-bottles-of-beer-2.ex
@@ -0,0 +1,36 @@
+last = [
+ """
+ 2 bottles of beer on the wall
+ 2 bottles of beer
+ Take one down, pass it around
+ 1 bottle of beer on the wall
+ """,
+ """
+ 1 bottle of beer on the wall
+ 1 bottle of beer
+ Take one down, pass it around
+ No bottles of beer on the wall
+ """,
+ """
+ No more bottles of beer on the wall
+ No more bottles of beer
+ Go to the store and buy some more
+ 99 bottles of beer on the wall
+ """
+]
+
+skeleton = fn n ->
+ """
+ #{n} bottles of beer on the wall
+ #{n} bottles of beer
+ Take one down, pass it around
+ #{n - 1} bottles of beer on the wall
+ """
+end
+
+99..3
+|> Stream.map(skeleton)
+|> Stream.concat(last)
+|> Enum.intersperse("\n")
+|> IO.iodata_to_binary()
+|> IO.puts()
diff --git a/Task/99-bottles-of-beer/Java/99-bottles-of-beer-5.java b/Task/99-bottles-of-beer/Java/99-bottles-of-beer-5.java
new file mode 100644
index 0000000000..394eb68af8
--- /dev/null
+++ b/Task/99-bottles-of-beer/Java/99-bottles-of-beer-5.java
@@ -0,0 +1,76 @@
+import java.util.Scanner;
+
+public class NineNineBottles {
+ static int bottlesOfBeer = 99;
+ static boolean hasBeer = true;
+ static Scanner keyboard = new Scanner(System.in);
+
+ public static void main(String[] args) {
+ beerCheck();
+ keyboard.close();
+ }
+
+ private static void beerCheck() {
+ if(hasBeer) {
+ party(bottlesOfBeer);
+ }
+
+ if(!hasBeer) {
+ System.out.println("Your ran out of beer. Would you like to go to the store?: ");
+ String blurryVision, fallingOver, youAreDrunk;
+ youAreDrunk = keyboard.nextLine();
+ fallingOver = "RUHFO" + youAreDrunk.toLowerCase() + "RUHFOISafhur";
+ blurryVision = fallingOver.split("[a-zA-Z]", 2).toString();
+ if(blurryVision.contains("y"))
+ blurryVision = blurryVision.substring(0, 1).toUpperCase();
+ System.out.println("You entered: " + blurryVision.toString() + fallingOver);
+ System.out.println("Did you mean yes?: ");
+ blurryVision = keyboard.nextLine();
+ if(blurryVision.contains("y") || blurryVision.contains("Y") || blurryVision.contains("8")
+ || blurryVision.contains("2") || blurryVision.equalsIgnoreCase(youAreDrunk))
+ {String beRECcheeck = blurryVision.toLowerCase();
+ if(beRECcheeck.equals("y")) {
+ goToStore();
+ beerCheck();
+ }
+ }
+ }
+ }
+
+ private static void party(int bottlesOfBeer) {
+ while(bottlesOfBeer > 1) {
+ putOnWall(bottlesOfBeer);
+ bottlesOfBeer = takeOneDown(bottlesOfBeer);
+ }
+ putLastOnWall(bottlesOfBeer);
+ }
+
+ private static void putOnWall(int bottlesOfBeer) {
+ System.out.printf("%d bottles of beer on the wall%n", bottlesOfBeer);
+
+ }
+
+ private static int takeOneDown(int bottlesOfBeer) {
+ System.out.printf("%d bottles of beer%n", bottlesOfBeer);
+ System.out.println("Take one down, pass it around");
+ bottlesOfBeer--;
+ putOnWall(bottlesOfBeer);
+ System.out.println();
+ return bottlesOfBeer;
+
+ }
+
+ private static void putLastOnWall(int bottleOfBeer) {
+ System.out.printf("%d bottle of beer on the wall%n", bottleOfBeer);
+ System.out.printf("%d bottle of beer%n", bottleOfBeer);
+ System.out.println("Take it down, pass it around");
+ bottleOfBeer--;
+ System.out.println("No more bottles of beer on the wall.");
+ hasBeer = false;
+ }
+
+ private static void goToStore() {
+ bottlesOfBeer = 99;
+ hasBeer = true;
+ }
+}
diff --git a/Task/99-bottles-of-beer/Nutt/99-bottles-of-beer.nutt b/Task/99-bottles-of-beer/Nutt/99-bottles-of-beer.nutt
index ccd2ec6780..fcac676e27 100644
--- a/Task/99-bottles-of-beer/Nutt/99-bottles-of-beer.nutt
+++ b/Task/99-bottles-of-beer/Nutt/99-bottles-of-beer.nutt
@@ -1,8 +1,8 @@
-module main imports native.io.output.say
+module main
+import $native 'io' : output#sayn
-for i|->{1,2..99;<|>) do
- say(""+i+" bottles of beer on the wall, "+i+" bottles of beer")
- say("Take one down and pass it around, "+(i-1)+" bottles of beer on the wall.")
-done
-
-end
+funct main () : () =
+ [1, 2; 99]#reverse#each {
+ sayn "\(it) bottles of beer on the wall, \(it) bottles of beer";
+ sayn "Take one down and pass it around, \(it# - 1) bottles of beer on the wall."
+ }
diff --git a/Task/99-bottles-of-beer/YAMLScript/99-bottles-of-beer-1.ys b/Task/99-bottles-of-beer/YAMLScript/99-bottles-of-beer-1.ys
index 2ad5b109ca..5dc37d24c9 100644
--- a/Task/99-bottles-of-beer/YAMLScript/99-bottles-of-beer-1.ys
+++ b/Task/99-bottles-of-beer/YAMLScript/99-bottles-of-beer-1.ys
@@ -1,4 +1,4 @@
-!yamlscript/v0
+!YS-v0
defn main(number=99):
each num (number .. 1):
diff --git a/Task/A+B/Guile/a+b.guile b/Task/A+B/Guile/a+b.guile
new file mode 100644
index 0000000000..d3ef4f223d
--- /dev/null
+++ b/Task/A+B/Guile/a+b.guile
@@ -0,0 +1,3 @@
+;;;Actually, the solution is same as that of many other Lisp dialects here
+(+ (read) (read))
+;;Yes, it is neat but not strong, error prone actually. Other than this walkaround, if you dislike fetching a line in string format then parse the chars one by one by hand or byte by byte from stdin, you can use one read and do the work, with the price of typing (1 2) instead of 1 2 at the prompt since read would treat the input as a symbolic expression. So.,.there is sadly no easy way like scanf and %d %d in c unless one is willing to type ()s!
diff --git a/Task/A+B/LOLCODE/a+b.lol b/Task/A+B/LOLCODE/a+b.lol
new file mode 100644
index 0000000000..711b24849b
--- /dev/null
+++ b/Task/A+B/LOLCODE/a+b.lol
@@ -0,0 +1,9 @@
+HAI 1.2
+ I HAS A VAR1 ITZ A YARN BTW DECLARE A VARIABLE FOR LATER USE
+ I HAS A VAR2 ITZ A YARN BTW DECLARE A VARIABLE FOR LATER USE
+ VISIBLE "NUMBAH 1?"
+ GIMMEH VAR1 BTW GET INPUT (NUMBER) INTO VARIABLE
+ VISIBLE "NUMBAH 2?"
+ GIMMEH VAR2 BTW GET INPUT (NUMBER) INTO VARIABLE
+ VISIBLE SUM OF VAR1 AN VAR2
+KTHXBYE
diff --git a/Task/A+B/Nutt/a+b.nutt b/Task/A+B/Nutt/a+b.nutt
index 50a609c5d5..5b0625667e 100644
--- a/Task/A+B/Nutt/a+b.nutt
+++ b/Task/A+B/Nutt/a+b.nutt
@@ -1,7 +1,8 @@
module main
-imports native.io{input.hear,output.say}
+import $native 'io' [input#hear output#sayn]
-vals a=hear(Int),b=hear(Int)
-say(a+b)
-
-end
+funct main () : () =
+ val read_int = {(hear ())#to_int#fold {0} {it}};
+ val a = read_int ();
+ val b = read_int ();
+ sayn (a# + b)
diff --git a/Task/A+B/Plain-English/a+b.plain b/Task/A+B/Plain-English/a+b.plain
index 01ffffe01a..4187b423eb 100644
--- a/Task/A+B/Plain-English/a+b.plain
+++ b/Task/A+B/Plain-English/a+b.plain
@@ -1,21 +1,42 @@
To run:
Start up.
- Read a number from the console.
- Read another number from the console.
- Output the sum of the number and the other number.
- Wait for the escape key.
+ Set up the console.
+ Write "Type the first number: " to Stdout.
+ Read a buffer from stdin.
+ Trim the buffer.
+ If the buffer is not any integer,
+ Write "Invalid input. Aborting Operation."
+ then the CRLF string to StdOut;
+ Shut down;
+ Exit.
+ Write "Type the second number: " to Stdout.
+ Read a second buffer from stdin.
+ Trim the second buffer.
+ If the second buffer is not any integer,
+ Write "Invalid input. Aborting Operation."
+ then the CRLF string to StdOut;
+ Shut down;
+ Exit.
+ Convert the buffer to a number.
+ Convert the second buffer to a second number.
+ Output the sum of the number and the second number.
Shut down.
To output the sum of a number and another number:
If the number is not valid,
- Write "Invalid input" to the console;
+ Write "Invalid input. Aborting Operation."
+ then the CRLF string to StdOut;
Exit.
If the other number is not valid,
- Write "Invalid input" to the console;
+ Write "Invalid input. Aborting Operation."
+ then the CRLF string to StdOut;
Exit.
- Write the number plus the other number then " is the sum." to the console.
+ Add the other number to the number.
+ Convert the number to a string called result.
+ Write "The sum is " then the result
+ then the CRLF string to StdOut.
To decide if a number is valid:
- If the number is not greater than or equal to -1000, say no.
- If the number is not less than or equal to 1000, say no.
+ If the number is less than -1000, say no.
+ If the number is greater than 1000, say no.
Say yes.
diff --git a/Task/A+B/ZED/a+b.zed b/Task/A+B/ZED/a+b.zed
index 6c28d79b86..b3605ef199 100644
--- a/Task/A+B/ZED/a+b.zed
+++ b/Task/A+B/ZED/a+b.zed
@@ -1,14 +1,14 @@
(A+B)
-comment:
+READ AND ADD
#true
(+) (read) (read)
(+) one two
-comment:
+=========
#true
(003) "+" one two
(read)
-comment:
+=========
#true
(001) "read"
diff --git a/Task/A+B/Zig/a+b.zig b/Task/A+B/Zig/a+b.zig
index fc0d17b9f6..378622f54f 100644
--- a/Task/A+B/Zig/a+b.zig
+++ b/Task/A+B/Zig/a+b.zig
@@ -1,25 +1,18 @@
const std = @import("std");
-const stdout = std.io.getStdOut().writer();
-
-const Input = enum { a, b };
pub fn main() !void {
var buf: [1024]u8 = undefined;
const reader = std.io.getStdIn().reader();
+ const stdout = std.io.getStdOut().writer();
+ try stdout.writeAll("Enter two integers separated by a space: ");
const input = try reader.readUntilDelimiter(&buf, '\n');
- const values = std.mem.trim(u8, input, "\x20");
+ const text = std.mem.trimRight(u8, input, "\r\n");
- var count: usize = 0;
- var split: usize = 0;
- for (values, 0..) |c, i| {
- if (!std.ascii.isDigit(c)) {
- count += 1;
- if (count == 1) split = i;
- }
- }
+ var it = std.mem.tokenizeScalar(u8, text, ' ');
+
+ const a = try std.fmt.parseInt(i64, it.next().?, 10);
+ const b = try std.fmt.parseInt(i64, it.next().?, 10);
- const a = try std.fmt.parseInt(u64, values[0..split], 10);
- const b = try std.fmt.parseInt(u64, values[split + count ..], 10);
try stdout.print("{d}\n", .{a + b});
}
diff --git a/Task/AKS-test-for-primes/FutureBasic/aks-test-for-primes.basic b/Task/AKS-test-for-primes/FutureBasic/aks-test-for-primes.basic
new file mode 100644
index 0000000000..c94e8f7494
--- /dev/null
+++ b/Task/AKS-test-for-primes/FutureBasic/aks-test-for-primes.basic
@@ -0,0 +1,102 @@
+// AKS Test for Primes task
+// https://rosettacode.org/wiki/AKS_test_for_primes
+// Translated from Yabasic to FutureBASIC
+
+
+#build ShowMoreWarnings NO
+
+begin globals
+ sInt64 c(100)
+ //double n
+end globals
+
+local fn coef(nx as short)
+ // out-by-1, ie coef(1)==^0, coef(2)==^1, coef(3)==^2 etc.
+ c(nx) = 1
+ short i
+ for i = nx-1 to 2 step -1
+ c(i) = c(i) + c(i-1)
+ next
+end fn
+
+local fn is_prime(nx as short) as boolean
+ short i
+ bool result = _false
+ fn coef(nx+1) // (I said it was out-by-1)
+ for i = 2 to nx-1 // (technically "to n" is more correct)
+ if int(c(i)/nx) <> c(i)/nx
+ return _false
+ end if
+ next
+
+ result = _true
+end fn = result
+
+local fn show(nx as short)
+ // (As per coef, this is (working) out-by-1)
+
+ double ci
+ str255 cix
+ short i
+
+ for i = nx to 1 step -1
+ ci = c(i)
+ if ci = 1
+ if (nx-i) mod 2 = 0
+ if i = 1
+ if nx = 1
+ cix = " 1"
+ else
+ cix = "+1"
+ end if
+ else
+ cix = ""
+ end if
+ else
+ cix = "-1"
+ end if
+ else
+ if (nx-i) mod 2 = 0
+ cix = "+" + str$(ci)
+ else
+ cix = "-" + str$(ci)
+ end if
+ end if
+
+ if i = 1 // ie ^0
+ print cix;
+ else
+ if i = 2 then print cix, "x"; // ie ^1
+ if i <> 2 then print cix, "x^", i-1;
+ end if
+
+ next i
+end fn
+
+local fn AKS_test_for_primes
+ short nx
+
+ for nx = 1 to 10 // (0 to 9 really)
+ fn coef(nx)
+ print "(x-1)^" + str$(nx-1) + " = ";
+ fn show(nx)
+ print
+ next
+
+ print
+ print "primes (<=53): ";
+ short n
+ c(2) = 1 // (this manages "", which is all that call did anyway...)
+ for n = 2 to 53
+ if fn is_prime(n)
+ print " ", n;
+ end if
+ next
+ print
+end fn
+
+window 1,@"AKS test for Primes",fn CGRectMake(0, 0, 850, 200)
+
+fn AKS_test_for_primes
+
+handleevents
diff --git a/Task/AKS-test-for-primes/REXX/aks-test-for-primes-3.rexx b/Task/AKS-test-for-primes/REXX/aks-test-for-primes-3.rexx
index 79dc451c4e..77862e7896 100644
--- a/Task/AKS-test-for-primes/REXX/aks-test-for-primes-3.rexx
+++ b/Task/AKS-test-for-primes/REXX/aks-test-for-primes-3.rexx
@@ -1,12 +1,14 @@
-parse version version; say version
-say 'AKS-test for Primes'; say
+include Settings
+
+say version
+say 'AKS-test for primes'; say
arg p
if p = '' then
p = 10
numeric digits Max(10,Abs(p)%3)
call Combis p
call Polynomials p
-call ShowPrimes p
+call Showprimes p
exit
Combis:
@@ -17,7 +19,7 @@ if p > 0 then
say 'Combinations up to' p'...'
else
say 'Combinations for' Abs(p)'...'
-say Combinations(p) 'Combinations generated'
+say Combinations(p) 'combinations generated'
say Format(Time('e'),,3) 'seconds'
say
return
@@ -33,9 +35,9 @@ else
b = 0
p = Abs(p); prim. = 0; n = 0
do i = b to p
- a = Ppower('1 -1',i)
+ a = Ppow('1 -1',i)
if i < 11 then
- say '(x-1)^'i '=' Parray2formula()
+ say '(x-1)^'i '=' Plst2form(Parr2lst())
s = 1
do j = 2 to poly.0-1
a = poly.coef.j
@@ -56,7 +58,7 @@ say Format(Time('e'),,3) 'seconds'
say
return
-ShowPrimes:
+Showprimes:
procedure expose prim.
arg p
call Time('r')
@@ -64,9 +66,9 @@ say 'Primes...'
if p < 0 then do
p = Abs(p)
if prim.0 > 0 then
- say p 'is Prime'
+ say p 'is prime'
else
- say p 'is not Prime'
+ say p 'is not prime'
end
else do
do i = 1 to prim.0
@@ -80,124 +82,8 @@ say Format(Time('e'),,3) 'seconds'
say
return
-Combinations:
-/* Combinations */
-procedure expose comb.
-arg xx
-/* Validate */
-if \ Whole(xx) then say abend
-/* Recurring definition */
-comb. = 1
-if xx < 0 then do
- xx = -xx; m = xx%2; a = 1
- do i = 1 to m
- a = a*(xx-i+1)/i; comb.xx.i = a
- end
- do i = m+1 to xx-1
- j = xx-i; comb.xx.i = comb.xx.j
- end
- return xx+1
-end
-else do
- do i = 1 to xx
- i1 = i-1
- do j = 1 to i1
- j1 = j-1; comb.i.j = comb.i1.j1+comb.i1.j
- end
- end
- return (xx*xx+3*xx+2)/2
-end
-
-Ppower:
-/* Exponentiation */
-procedure expose poly. comb. work.
-arg x,y
-/* Validate */
-if x = '' then say abend
-if \ Whole(y) then say abend
-if y < 0 then say abend
-/* Exponentiate */
-numeric digits Digits()+2
-wx = Words(x); wm = wx*y-y+1
-poly. = 0; poly.0 = wm
-select
- when wx = 1 then
-/* Power of a number */
- poly.coef.1 = x**y
- when wx = 2 then do
-/* Newton's binomial */
- a = Word(x,1); b = Word(x,2)
- do i = 1 to wm
- j = y-i+1; k = i-1
- poly.coef.i = comb.y.k*a**j*b**k
- end
- end
- otherwise do
-/* Repeated multiplication */
- do i = 1 to wx
- poly.coef.1.i = Word(x,i)
- poly.coef.2.i = poly.coef.1.i
- end
- wy = wx
- do i = 2 to y
- work. = 0
- do j = 1 to wx
- do k = 1 to wy
- l = j+k-1; work.coef.l = work.coef.l+poly.coef.1.j*poly.coef.2.k
- end
- end
- if i = y then
- leave i
- wx = wx+wy-1
- do j = 1 to wx
- poly.coef.1.j = work.coef.j
- end
- end
- do i = 1 to wm
- poly.coef.i = work.coef.i
- end
- end
-end
-numeric digits Digits()-2
-/* Normalize coefs */
-call Pnormalize
-return wm
-
-Parray2formula:
-/* Array -> Formula */
-procedure expose poly.
-/* Generate formula */
-y = ''; wm = poly.0
-do i = 1 to wm
- a = poly.coef.i
- if a <> 0 then do
- select
- when a < 0 then
- s = '-'
- when i > 1 then
- s = '+'
- otherwise
- s = ''
- end
- a = Abs(a); e = wm-i
- if a = 1 & e > 0 then
- a = ''
- select
- when e > 1 then
- b = 'x^'e
- when e = 1 then
- b = 'x'
- otherwise
- b = ''
- end
- y = y||s||a||b
- end
-end
-if y = '' then
- y = 0
-return Strip(y)
-
include Functions
include Numbers
include Polynomial
include Sequences
+include Abend
diff --git a/Task/ASCII-art-diagram-converter/Chipmunk-Basic/ascii-art-diagram-converter.basic b/Task/ASCII-art-diagram-converter/Chipmunk-Basic/ascii-art-diagram-converter.basic
new file mode 100644
index 0000000000..54092c2681
--- /dev/null
+++ b/Task/ASCII-art-diagram-converter/Chipmunk-Basic/ascii-art-diagram-converter.basic
@@ -0,0 +1,84 @@
+100 cls
+110 type tableentry
+120 nombre as string *8
+130 bits as integer
+140 startpos as integer
+150 length as integer
+160 end type
+170 dim hexmap$(15)
+180 hexmap$(0) = "0000" : hexmap$(1) = "0001" : hexmap$(2) = "0010" : hexmap$(3) = "0011"
+190 hexmap$(4) = "0100" : hexmap$(5) = "0101" : hexmap$(6) = "0110" : hexmap$(7) = "0111"
+200 hexmap$(8) = "1000" : hexmap$(9) = "1001" : hexmap$(10) = "1010" : hexmap$(11) = "1011"
+210 hexmap$(12) = "1100" : hexmap$(13) = "1101" : hexmap$(14) = "1110" : hexmap$(15) = "1111"
+220 dim fields(12) as tableentry
+230 header$ = " +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+"+chr$(10)
+240 header$ = header$+" | ID |"+chr$(10)
+250 header$ = header$+" +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+"+chr$(10)
+260 header$ = header$+" |QR| Opcode |AA|TC|RD|RA| Z | RCODE |"+chr$(10)
+270 header$ = header$+" +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+"+chr$(10)
+280 header$ = header$+" | QDCOUNT |"+chr$(10)
+290 header$ = header$+" +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+"+chr$(10)
+300 header$ = header$+" | ANCOUNT |"+chr$(10)
+310 header$ = header$+" +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+"+chr$(10)
+320 header$ = header$+" | NSCOUNT |"+chr$(10)
+330 header$ = header$+" +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+"+chr$(10)
+340 header$ = header$+" | ARCOUNT |"+chr$(10)
+350 header$ = header$+" +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+"
+360 fields(0).nombre = " ID " : fields(0).bits = 16 : fields(0).startpos = 0 : fields(0).length = 16
+370 fields(1).nombre = " QR " : fields(1).bits = 1 : fields(1).startpos = 16 : fields(1).length = 1
+380 fields(2).nombre = " Opcode " : fields(2).bits = 4 : fields(2).startpos = 17 : fields(2).length = 4
+390 fields(3).nombre = " AA " : fields(3).bits = 1 : fields(3).startpos = 21 : fields(3).length = 1
+400 fields(4).nombre = " TC " : fields(4).bits = 1 : fields(4).startpos = 22 : fields(4).length = 1
+410 fields(5).nombre = " RD " : fields(5).bits = 1 : fields(5).startpos = 23 : fields(5).length = 1
+420 fields(6).nombre = " RA " : fields(6).bits = 1 : fields(6).startpos = 24 : fields(6).length = 1
+430 fields(7).nombre = " Z " : fields(7).bits = 3 : fields(7).startpos = 25 : fields(7).length = 3
+440 fields(8).nombre = " RCODE " : fields(8).bits = 4 : fields(8).startpos = 28 : fields(8).length = 4
+450 fields(9).nombre = "QDCOUNT " : fields(9).bits = 16 : fields(9).startpos = 32 : fields(9).length = 16
+460 fields(10).nombre = "ANCOUNT " : fields(10).bits = 16 : fields(10).startpos = 48 : fields(10).length = 16
+470 fields(11).nombre = "NSCOUNT " : fields(11).bits = 16 : fields(11).startpos = 64 : fields(11).length = 16
+480 fields(12).nombre = "ARCOUNT " : fields(12).bits = 16 : fields(12).startpos = 80 : fields(12).length = 16
+490 hexstr$ = "78477bbf5496e12e1bf169a4"
+500 binstr$ = hextobinary$(hexstr$)
+510 print "RFC 1035 message diagram header:"
+520 print header$
+530 print
+540 print " Decoded:"
+550 print " Name Bits Start End"
+560 print " ======= ==== ===== ==="
+570 for i = 0 to 12
+580 print " ";fields(i).nombre;" ";
+581 print using "####";fields(i).bits;" ";
+600 print using "#####";fields(i).startpos;" ";
+601 print using "###";fields(i).startpos+fields(i).length-1
+610 next i
+620 print
+630 print " Test string in hex:"
+640 print " ";hexstr$
+650 print
+660 print " Test string in binary:"
+670 print " ";binstr$
+680 print
+690 print " Unpacked:"
+700 print " Name Size Bit Pattern"
+710 print " ======= ==== ================"
+720 for i = 0 to 12
+730 bitpattern$ = mid$(binstr$,fields(i).startpos+1,fields(i).length)
+740 bitpattern$ = left$(bitpattern$+" ",16)
+760 print " ";fields(i).nombre;" ";
+770 print using "####";fields(i).bits;" ";
+780 print bitpattern$
+790 next i
+800 end
+810 sub hextobinary$(hexstring$)
+820 result$ = ""
+830 for i = 1 to len(hexstring$)
+840 hexdigit$ = ucase$(mid$(hexstring$,i,1))
+850 if hexdigit$ >= "0" and hexdigit$ <= "9" then
+860 idx = val(hexdigit$)
+870 else
+880 idx = asc(hexdigit$)-asc("A")+10
+890 endif
+900 if idx >= 0 and idx <= 15 then result$ = result$+hexmap$(idx)
+910 next i
+920 hextobinary$ = result$
+930 end sub
diff --git a/Task/ASCII-art-diagram-converter/FreeBASIC/ascii-art-diagram-converter.basic b/Task/ASCII-art-diagram-converter/FreeBASIC/ascii-art-diagram-converter.basic
new file mode 100644
index 0000000000..6501672dfa
--- /dev/null
+++ b/Task/ASCII-art-diagram-converter/FreeBASIC/ascii-art-diagram-converter.basic
@@ -0,0 +1,92 @@
+Type TableEntry
+ nombre As String * 8
+ bits As Integer
+ startPos As Integer
+ length As Integer
+End Type
+
+Function HexToBinary(hexString As String) As String
+ Dim As Integer i, idx
+ Dim As String hexDigit, result = ""
+
+ ' Create hex to binary mapping
+ Dim As String hexMap(15) = { _
+ "0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111", _
+ "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111" }
+
+ For i = 0 To Len(hexString) - 1
+ hexDigit = Ucase(Mid(hexString, i + 1, 1))
+ ' Convert hex digit to index
+ idx = Iif(hexDigit >= "0" And hexDigit <= "9", Val(hexDigit), Asc(hexDigit) - Asc("A") + 10)
+ If idx >= 0 And idx <= 15 Then result &= hexMap(idx)
+ Next
+ Return result
+End Function
+
+Sub ParseASCIIArt()
+ Dim As String header = _
+ " +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" & Chr(10) & _
+ " | ID |" & Chr(10) & _
+ " +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" & Chr(10) & _
+ " |QR| Opcode |AA|TC|RD|RA| Z | RCODE |" & Chr(10) & _
+ " +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" & Chr(10) & _
+ " | QDCOUNT |" & Chr(10) & _
+ " +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" & Chr(10) & _
+ " | ANCOUNT |" & Chr(10) & _
+ " +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" & Chr(10) & _
+ " | NSCOUNT |" & Chr(10) & _
+ " +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" & Chr(10) & _
+ " | ARCOUNT |" & Chr(10) & _
+ " +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+"
+
+ Dim As TableEntry fields(12) = { _
+ (" ID ", 16, 0, 16), _
+ (" QR ", 1, 16, 1), _
+ (" Opcode ", 4, 17, 4), _
+ (" AA ", 1, 21, 1), _
+ (" TC ", 1, 22, 1), _
+ (" RD ", 1, 23, 1), _
+ (" RA ", 1, 24, 1), _
+ (" Z ", 3, 25, 3), _
+ (" RCODE ", 4, 28, 4), _
+ ("QDCOUNT ", 16, 32, 16), _
+ ("ANCOUNT ", 16, 48, 16), _
+ ("NSCOUNT ", 16, 64, 16), _
+ ("ARCOUNT ", 16, 80, 16) }
+
+ Dim As String hexStr = "78477bbf5496e12e1bf169a4"
+ Dim As String binStr = HexToBinary(hexStr)
+ Dim As Integer i
+
+ ' Print header
+ Print "RFC 1035 message diagram header:"
+ Print header
+
+ ' Print decoded fields
+ Print !"\n Decoded:"
+ Print !" Name Bits Start End\n ======= ==== ===== ==="
+
+ For i = 0 To 12
+ Print Using " \ \ #### ##### ###"; _
+ fields(i).nombre; _
+ fields(i).bits; _
+ fields(i).startPos; _
+ fields(i).startPos + fields(i).length - 1
+ Next
+
+ Print !"\n Test string in hex:\n " & hexStr
+ Print !"\n Test string in binary:\n " & binStr
+ Print !"\n Unpacked:"
+ Print !" Name Size Bit Pattern\n ======= ==== ==============="
+
+ For i = 0 To 12
+ Print Using " \ \ #### \ \"; _
+ fields(i).nombre; _
+ fields(i).bits; _
+ Left(Mid(binStr, fields(i).startPos + 1, fields(i).length) + Space(16), 16)
+ Next
+End Sub
+
+ParseASCIIArt()
+
+Sleep
diff --git a/Task/ASCII-art-diagram-converter/PureBasic/ascii-art-diagram-converter.basic b/Task/ASCII-art-diagram-converter/PureBasic/ascii-art-diagram-converter.basic
new file mode 100644
index 0000000000..b682c629b1
--- /dev/null
+++ b/Task/ASCII-art-diagram-converter/PureBasic/ascii-art-diagram-converter.basic
@@ -0,0 +1,94 @@
+Structure TableEntry
+ nombre.s
+ bits.i
+ startPos.i
+ length.i
+EndStructure
+
+Procedure.s HexToBinary(hexString.s)
+ Dim hexMap.s(15)
+ hexMap(0) = "0000" : hexMap(1) = "0001" : hexMap(2) = "0010" : hexMap(3) = "0011"
+ hexMap(4) = "0100" : hexMap(5) = "0101" : hexMap(6) = "0110" : hexMap(7) = "0111"
+ hexMap(8) = "1000" : hexMap(9) = "1001" : hexMap(10) = "1010" : hexMap(11) = "1011"
+ hexMap(12) = "1100" : hexMap(13) = "1101" : hexMap(14) = "1110" : hexMap(15) = "1111"
+
+ Protected.s result = "", hexDigit
+ Protected.i idx
+
+ For i = 0 To Len(hexString) - 1
+ hexDigit = UCase(Mid(hexString, i + 1, 1))
+ If hexDigit >= "0" And hexDigit <= "9"
+ idx = Val(hexDigit)
+ Else
+ idx = Asc(hexDigit) - Asc("A") + 10
+ EndIf
+ If idx >= 0 And idx <= 15
+ result + hexMap(idx)
+ EndIf
+ Next
+
+ ProcedureReturn result
+EndProcedure
+
+Procedure ParseASCIIArt()
+ Protected header.s = " +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" + #CRLF$ +
+ " | ID |" + #CRLF$ +
+ " +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" + #CRLF$ +
+ " |QR| Opcode |AA|TC|RD|RA| Z | RCODE |" + #CRLF$ +
+ " +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" + #CRLF$ +
+ " | QDCOUNT |" + #CRLF$ +
+ " +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" + #CRLF$ +
+ " | ANCOUNT |" + #CRLF$ +
+ " +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" + #CRLF$ +
+ " | NSCOUNT |" + #CRLF$ +
+ " +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" + #CRLF$ +
+ " | ARCOUNT |" + #CRLF$ +
+ " +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+"
+
+ Dim fields.TableEntry(12)
+ fields(0)\nombre = " ID " : fields(0)\bits = 16 : fields(0)\startPos = 0 : fields(0)\length = 16
+ fields(1)\nombre = " QR " : fields(1)\bits = 1 : fields(1)\startPos = 16 : fields(1)\length = 1
+ fields(2)\nombre = " Opcode " : fields(2)\bits = 4 : fields(2)\startPos = 17 : fields(2)\length = 4
+ fields(3)\nombre = " AA " : fields(3)\bits = 1 : fields(3)\startPos = 21 : fields(3)\length = 1
+ fields(4)\nombre = " TC " : fields(4)\bits = 1 : fields(4)\startPos = 22 : fields(4)\length = 1
+ fields(5)\nombre = " RD " : fields(5)\bits = 1 : fields(5)\startPos = 23 : fields(5)\length = 1
+ fields(6)\nombre = " RA " : fields(6)\bits = 1 : fields(6)\startPos = 24 : fields(6)\length = 1
+ fields(7)\nombre = " Z " : fields(7)\bits = 3 : fields(7)\startPos = 25 : fields(7)\length = 3
+ fields(8)\nombre = " RCODE " : fields(8)\bits = 4 : fields(8)\startPos = 28 : fields(8)\length = 4
+ fields(9)\nombre = "QDCOUNT " : fields(9)\bits = 16 : fields(9)\startPos = 32 : fields(9)\length = 16
+ fields(10)\nombre = "ANCOUNT " : fields(10)\bits = 16 : fields(10)\startPos = 48 : fields(10)\length = 16
+ fields(11)\nombre = "NSCOUNT " : fields(11)\bits = 16 : fields(11)\startPos = 64 : fields(11)\length = 16
+ fields(12)\nombre = "ARCOUNT " : fields(12)\bits = 16 : fields(12)\startPos = 80 : fields(12)\length = 16
+
+ Protected hexStr.s = "78477bbf5496e12e1bf169a4"
+ Protected binStr.s = HexToBinary(hexStr)
+
+ PrintN("RFC 1035 message diagram header:")
+ PrintN(header)
+ PrintN(#CRLF$ + " Decoded:")
+ PrintN(" Name Bits Start End" + #CRLF$ + " ======= ==== ===== ===")
+
+ For i = 0 To 12
+ PrintN(RSet(fields(i)\nombre, 9) + " " + RSet(Str(fields(i)\bits), 4) + " " +
+ RSet(Str(fields(i)\startPos), 6) + " " + RSet(Str(fields(i)\startPos + fields(i)\length - 1), 4))
+ Next
+
+ PrintN(#CRLF$ + " Test string in hex:")
+ PrintN(" " + hexStr)
+ PrintN(#CRLF$ + " Test string in binary:")
+ PrintN(" " + binStr)
+ PrintN(#CRLF$ + " Unpacked:")
+ PrintN(" Name Size Bit Pattern" + #CRLF$ + " ======= ==== ================")
+
+ For i = 0 To 12
+ bitPattern.s = Mid(binStr, fields(i)\startPos + 1, fields(i)\length)
+ bitPattern = Left(bitPattern + Space(16), 16)
+ PrintN(RSet(fields(i)\nombre, 9) + " " + RSet(Str(fields(i)\bits), 4) + " " + bitPattern)
+ Next
+EndProcedure
+
+OpenConsole()
+
+ParseASCIIArt()
+PrintN(#CRLF$ + "Press ENTER to exit"): Input()
+CloseConsole()
diff --git a/Task/ASCII-art-diagram-converter/QBasic/ascii-art-diagram-converter.basic b/Task/ASCII-art-diagram-converter/QBasic/ascii-art-diagram-converter.basic
new file mode 100644
index 0000000000..a5c32ea3b5
--- /dev/null
+++ b/Task/ASCII-art-diagram-converter/QBasic/ascii-art-diagram-converter.basic
@@ -0,0 +1,95 @@
+DECLARE SUB ParseASCIIArt ()
+DECLARE FUNCTION HexToBinary$ (hexString AS STRING)
+
+TYPE TableEntry
+ nombre AS STRING * 8
+ bits AS INTEGER
+ startPos AS INTEGER
+ length AS INTEGER
+END TYPE
+
+ParseASCIIArt
+END
+
+FUNCTION HexToBinary$ (hexString AS STRING)
+ DIM hexMap(15) AS STRING
+ hexMap(0) = "0000": hexMap(1) = "0001": hexMap(2) = "0010": hexMap(3) = "0011"
+ hexMap(4) = "0100": hexMap(5) = "0101": hexMap(6) = "0110": hexMap(7) = "0111"
+ hexMap(8) = "1000": hexMap(9) = "1001": hexMap(10) = "1010": hexMap(11) = "1011"
+ hexMap(12) = "1100": hexMap(13) = "1101": hexMap(14) = "1110": hexMap(15) = "1111"
+
+ result$ = ""
+ FOR i = 0 TO LEN(hexString) - 1
+ hexDigit$ = UCASE$(MID$(hexString, i + 1, 1))
+ IF hexDigit$ >= "0" AND hexDigit$ <= "9" THEN
+ idx = VAL(hexDigit$)
+ ELSE
+ idx = ASC(hexDigit$) - ASC("A") + 10
+ END IF
+ IF idx >= 0 AND idx <= 15 THEN result$ = result$ + hexMap(idx)
+ NEXT
+ HexToBinary$ = result$
+END FUNCTION
+
+SUB ParseASCIIArt
+ DIM header AS STRING
+ header = " +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" + CHR$(10)
+ header = header + " | ID |" + CHR$(10)
+ header = header + " +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" + CHR$(10)
+ header = header + " |QR| Opcode |AA|TC|RD|RA| Z | RCODE |" + CHR$(10)
+ header = header + " +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" + CHR$(10)
+ header = header + " | QDCOUNT |" + CHR$(10)
+ header = header + " +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" + CHR$(10)
+ header = header + " | ANCOUNT |" + CHR$(10)
+ header = header + " +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" + CHR$(10)
+ header = header + " | NSCOUNT |" + CHR$(10)
+ header = header + " +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+" + CHR$(10)
+ header = header + " | ARCOUNT |" + CHR$(10)
+ header = header + " +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+"
+
+ DIM fields(12) AS TableEntry
+ fields(0).nombre = " ID ": fields(0).bits = 16: fields(0).startPos = 0: fields(0).length = 16
+ fields(1).nombre = " QR ": fields(1).bits = 1: fields(1).startPos = 16: fields(1).length = 1
+ fields(2).nombre = " Opcode ": fields(2).bits = 4: fields(2).startPos = 17: fields(2).length = 4
+ fields(3).nombre = " AA ": fields(3).bits = 1: fields(3).startPos = 21: fields(3).length = 1
+ fields(4).nombre = " TC ": fields(4).bits = 1: fields(4).startPos = 22: fields(4).length = 1
+ fields(5).nombre = " RD ": fields(5).bits = 1: fields(5).startPos = 23: fields(5).length = 1
+ fields(6).nombre = " RA ": fields(6).bits = 1: fields(6).startPos = 24: fields(6).length = 1
+ fields(7).nombre = " Z ": fields(7).bits = 3: fields(7).startPos = 25: fields(7).length = 3
+ fields(8).nombre = " RCODE ": fields(8).bits = 4: fields(8).startPos = 28: fields(8).length = 4
+ fields(9).nombre = "QDCOUNT ": fields(9).bits = 16: fields(9).startPos = 32: fields(9).length = 16
+ fields(10).nombre = "ANCOUNT ": fields(10).bits = 16: fields(10).startPos = 48: fields(10).length = 16
+ fields(11).nombre = "NSCOUNT ": fields(11).bits = 16: fields(11).startPos = 64: fields(11).length = 16
+ fields(12).nombre = "ARCOUNT ": fields(12).bits = 16: fields(12).startPos = 80: fields(12).length = 16
+
+ hexStr$ = "78477bbf5496e12e1bf169a4"
+ binStr$ = HexToBinary$(hexStr$)
+
+ PRINT "RFC 1035 message diagram header:"
+ PRINT header
+ PRINT
+ PRINT " Decoded:"
+ PRINT " Name Bits Start End"
+ PRINT " ======= ==== ===== ==="
+
+ FOR i = 0 TO 12
+ PRINT USING " \ \ #### ##### ###"; fields(i).nombre; fields(i).bits; fields(i).startPos; fields(i).startPos + fields(i).length - 1
+ NEXT
+
+ PRINT
+ PRINT " Test string in hex:"
+ PRINT " "; hexStr$
+ PRINT
+ PRINT " Test string in binary:"
+ PRINT " "; binStr$
+ PRINT
+ PRINT " Unpacked:"
+ PRINT " Name Size Bit Pattern"
+ PRINT " ======= ==== ==============="
+
+ FOR i = 0 TO 12
+ bitPattern$ = MID$(binStr$, fields(i).startPos + 1, fields(i).length)
+ bitPattern$ = LEFT$(bitPattern$ + SPACE$(16), 16)
+ PRINT USING " \ \ #### \ \"; fields(i).nombre; fields(i).bits; bitPattern$
+ NEXT
+END SUB
diff --git a/Task/Abbreviations-automatic/Crystal/abbreviations-automatic.cr b/Task/Abbreviations-automatic/Crystal/abbreviations-automatic.cr
new file mode 100644
index 0000000000..fb78aea856
--- /dev/null
+++ b/Task/Abbreviations-automatic/Crystal/abbreviations-automatic.cr
@@ -0,0 +1,12 @@
+def auto_abbreviate (string)
+ words = string.split
+ return nil unless words.present?
+ (1..words.max_of(&.size)).each do |n|
+ return n if words.map(&.[0, n]).to_set.size == words.size
+ end
+ "∞"
+end
+
+File.read_lines("weekdays.txt").each_with_index do |line, i|
+ puts "#{i+1}) #{auto_abbreviate(line)} #{line}"
+end
diff --git a/Task/Abbreviations-simple/M2000-Interpreter/abbreviations-simple-3.m2000 b/Task/Abbreviations-simple/M2000-Interpreter/abbreviations-simple-3.m2000
new file mode 100644
index 0000000000..e710dbc3c6
--- /dev/null
+++ b/Task/Abbreviations-simple/M2000-Interpreter/abbreviations-simple-3.m2000
@@ -0,0 +1,71 @@
+Module Abbreviations_simple {
+ commands=list
+ a$="add 1 alter 3 backup 2 bottom 1 Cappend 2 change 1 Schange Cinsert 2 Clast 3 "
+ a$+="compress 4 copy 2 count 3 Coverlay 3 cursor 3 delete 3 Cdelete 2 down 1 duplicate "
+ a$+="3 xEdit 1 expand 3 extract 3 find 1 Nfind 2 Nfindup 6 NfUP 3 Cfind 2 findUP 3 fUP 2 "
+ a$+="forward 2 get help 1 hexType 4 input 1 powerInput 3 join 1 split 2 spltJOIN load "
+ a$+="locate 1 Clocate 2 lowerCase 3 upperCase 3 Lprefix 2 macro merge 2 modify 3 move 2 "
+ a$+="msg next 1 overlay 1 parse preserve 4 purge 3 put putD query 1 quit read recover 3 "
+ a$+="refresh renum 3 repeat 3 replace 1 Creplace 2 reset 3 restore 4 rgtLEFT right 2 left "
+ a$+="2 save set shift 2 si sort sos stack 3 status 4 top transfer 3 type 1 up 1"
+ gosub cleanspaces
+ gosub makelist
+ if not empty then gosub processstack
+ a$="riG rePEAT copies put mo rest types fup. 6 poweRin"
+ Print a$
+ gosub cleanspaces
+ gosub findresult
+ a$="riG macro copies macr"
+ Print a$
+ gosub cleanspaces
+ gosub findresult
+ End
+processstack:
+ Read many, word$
+ if many>0 and many"" then data 0, ucase$(w$):w$=""
+ end if
+ next
+ return
+findresult:
+ dim a$()
+ a$()=piece$(ucase$(a$), " ")
+ flush
+ for i=0 to len(a$())-1
+ if exist(commands, a$(i)) then
+ Data eval$(commands)
+ else
+ Data "*error*"
+ end if
+ next
+ Print Array([])#str$(" ")
+ Return
+}
+Abbreviations_simple
diff --git a/Task/Abbreviations-simple/NewLISP/abbreviations-simple.l b/Task/Abbreviations-simple/NewLISP/abbreviations-simple.l
index 2f137ce9e2..67b0ad7999 100644
--- a/Task/Abbreviations-simple/NewLISP/abbreviations-simple.l
+++ b/Task/Abbreviations-simple/NewLISP/abbreviations-simple.l
@@ -32,6 +32,6 @@
(push (or found? "*error*") result -1))
(join result " "))))
-(foo
+(println (foo
"riG rePEAT copies put mo rest types fup. 6 poweRin"
-)
+))
diff --git a/Task/Abstract-type/Arturo/abstract-type.arturo b/Task/Abstract-type/Arturo/abstract-type.arturo
new file mode 100644
index 0000000000..ffff513cd7
--- /dev/null
+++ b/Task/Abstract-type/Arturo/abstract-type.arturo
@@ -0,0 +1,35 @@
+define :queue [
+ init: method [][
+ \items: []
+ ]
+
+ enqueue: method [item][
+ panic "enqueue must be implemented by concrete type"
+ ]
+
+ dequeue: method [][
+ panic "dequeue must be implemented by concrete type"
+ ]
+]
+
+define :simpleQueue is :queue [
+ enqueue: method [item][
+ \items: \items ++ item
+ ]
+
+ dequeue: method [][
+ if empty? \items -> return null
+ ret: first \items
+ \items: drop \items
+ return ret
+ ]
+]
+
+q: to :simpleQueue []!
+
+q\enqueue "first"
+q\enqueue "second"
+
+print q\dequeue
+print q\dequeue
+print q\dequeue
diff --git a/Task/Achilles-numbers/FutureBasic/achilles-numbers.basic b/Task/Achilles-numbers/FutureBasic/achilles-numbers.basic
new file mode 100644
index 0000000000..194d6b3e21
--- /dev/null
+++ b/Task/Achilles-numbers/FutureBasic/achilles-numbers.basic
@@ -0,0 +1,90 @@
+NSInteger local fn GCD( n as NSInteger, d as NSInteger )
+ if ( d == 0 ) then return n else return fn GCD( d, n % d )
+end fn = 0
+
+NSInteger local fn Totient( n as NSInteger )
+ NSInteger tot = 0
+ for NSInteger m = 1 to n
+ if fn GCD( m, n ) = 1 then tot++
+ next
+ return tot
+end fn = 0
+
+BOOL local fn IsPowerful( m as NSInteger )
+ int n = m
+ int f = 2
+ double l = sqr(m)
+
+ if m <= 1 then return NO
+ while ( YES )
+ NSInteger q = n / f
+ if ( n % f ) == 0
+ if ( m % (f * f) ) then return NO
+ n = q
+ if f > n then exit while
+ else
+ f++
+ if ( f > l )
+ if ( m % (n * n) ) then return NO
+ exit while
+ end if
+ end if
+ wend
+end fn = YES
+
+BOOL local fn IsAchilles( n as NSInteger )
+ if fn IsPowerful(n) == NO then return NO
+ NSInteger m = 2
+ NSInteger a = m * m
+ do
+ do
+ if a == n then return NO
+ a *= m
+ until ( a > n )
+ m++
+ a = m * m
+ until ( a > n )
+end fn = YES
+
+local fn AchillesNumbers
+ print "First 50 Achilles numbers:"
+ NSInteger num = 0
+ NSInteger n = 1
+
+ CFTimeInterval t : t = fn CACurrentMediaTime
+ do
+ if fn IsAchilles( n )
+ printf @"%4d \b", n
+ num++
+ if ( num % 10 ) != 0 then printf @" \b" else print
+ end if
+ n++
+ until ( num >= 50 )
+
+ printf @"\n\nFirst 20 strong Achilles numbers:"
+ num = 0
+ n = 1
+ do
+ if fn IsAchilles(n) && fn IsAchilles( fn Totient(n) )
+ printf @"%5d \b", n
+ num++
+ if ( num % 5 ) != 0 then printf @" \b" else print
+ end if
+ n++
+ until ( num >= 20 )
+
+ printf @"\n"
+ for NSInteger i = 2 to 6
+ NSInteger inicio = fix( 10.0 ^ (i-1) )
+ num = 0
+ for n = inicio to inicio * 10 -1
+ if fn IsAchilles(n) then num++
+ next
+ printf @"Achilles numbers with %d digits: %d", i, num
+ next
+ printf @"\nCompute time: %.3f ms", (fn CACurrentMediaTime - t ) * 1000
+end fn
+
+fn AchillesNumbers
+
+HandleEvents
diff --git a/Task/Achilles-numbers/PARI-GP/achilles-numbers.parigp b/Task/Achilles-numbers/PARI-GP/achilles-numbers.parigp
new file mode 100644
index 0000000000..44391a9b19
--- /dev/null
+++ b/Task/Achilles-numbers/PARI-GP/achilles-numbers.parigp
@@ -0,0 +1,8 @@
+is(n,f=factor(n))=gcd(f[,2])==1 && vecmin(f[,2])>1
+first(n)=my(v=List()); forfactored(k=1,10^9, if(is(k[1],k[2]), listput(v,k[1]); if(#v==n, return(Vec(v)))))
+firstStrong(n)=my(v=List()); forfactored(k=1,10^9, if(is(k[1],k[2]) && is(eulerphi(k)), listput(v,k[1]); if(#v==n, return(Vec(v)))))
+countBetween(a,b)=my(s); forfactored(k=a,b, if(is(k[1],k[2]), s++)); s
+countDigits(n)=countBetween(10^(n-1),10^n-1)
+first(50)
+firstStrong(20)
+apply(countDigits, [2..5])
diff --git a/Task/Ackermann-function/ZED/ackermann-function.zed b/Task/Ackermann-function/ZED/ackermann-function.zed
index a16fe385ad..af5d1c0f49 100644
--- a/Task/Ackermann-function/ZED/ackermann-function.zed
+++ b/Task/Ackermann-function/ZED/ackermann-function.zed
@@ -1,29 +1,29 @@
-(A) m n
-comment:
+(a) m n
+M ZERO
(=) m 0
(add1) n
-(A) m n
-comment:
+(a) m n
+N ZERO
(=) n 0
-(A) (sub1) m 1
+(a) (sub1) m 1
-(A) m n
-comment:
+(a) m n
+DEFAULT
#true
-(A) (sub1) m (A) m (sub1) n
+(a) (sub1) m (a) m (sub1) n
(add1) n
-comment:
+=========
#true
(003) "+" n 1
(sub1) n
-comment:
+=========
#true
(003) "-" n 1
(=) n1 n2
-comment:
+=========
#true
(003) "=" n1 n2
diff --git a/Task/Additive-primes/Fortran/additive-primes.f b/Task/Additive-primes/Fortran/additive-primes.f
new file mode 100644
index 0000000000..fe0cf1cf05
--- /dev/null
+++ b/Task/Additive-primes/Fortran/additive-primes.f
@@ -0,0 +1,66 @@
+program AdditivePrimes
+ implicit none
+
+ integer :: i, j, digit_sum, count
+ logical :: is_prime
+
+ ! Arrays to track prime numbers and additive primes
+ logical, dimension(500) :: prime_check
+ logical, dimension(500) :: additive_prime_check
+
+ ! Initialize arrays
+ prime_check = .true.
+ prime_check(1) = .false.
+ additive_prime_check = .false.
+
+ ! Sieve of Eratosthenes to find primes
+ do i = 2, int(sqrt(real(500)))
+ if (prime_check(i)) then
+ do j = i*i, 500, i
+ prime_check(j) = .false.
+ end do
+ end if
+ end do
+
+ ! Find additive primes
+ count = 0
+ do i = 2, 500
+ if (prime_check(i)) then
+ ! Calculate digit sum
+ digit_sum = sum_digits(i)
+
+ ! Check if digit sum is also prime
+ if (prime_check(digit_sum)) then
+ additive_prime_check(i) = .true.
+ count = count + 1
+ end if
+ end if
+ end do
+
+ ! Print results
+ print *, "Additive Primes less than 500:"
+ do i = 2, 500
+ if (additive_prime_check(i)) then
+ print *, i
+ end if
+ end do
+
+ print *, "Total number of additive primes:", count
+
+ contains
+
+ ! Function to calculate sum of digits
+ function sum_digits(num) result(total)
+ integer, intent(in) :: num
+ integer :: total, temp_num
+
+ total = 0
+ temp_num = num
+
+ do while (temp_num > 0)
+ total = total + mod(temp_num, 10)
+ temp_num = temp_num / 10
+ end do
+ end function sum_digits
+
+ end program AdditivePrimes
diff --git a/Task/Additive-primes/Langur/additive-primes.langur b/Task/Additive-primes/Langur/additive-primes.langur
index 19042c8a58..70cff53c32 100644
--- a/Task/Additive-primes/Langur/additive-primes.langur
+++ b/Task/Additive-primes/Langur/additive-primes.langur
@@ -1,15 +1,15 @@
val isPrime = fn(i) {
i == 2 or i > 2 and
- not any(fn x: i div x, pseries(2 .. i ^/ 2))
+ not any(series(2 .. i ^/ 2, asconly=true), by=fn x:i div x)
}
-val sumDigits = fn i: fold(fn{+}, s2n(string(i)))
+val sumDigits = fn i: fold(s2n(string(i)), by=fn{+})
writeln "Additive primes less than 500:"
var cnt = 0
-for i in [2] ~ series(3..500, 2) {
+for i in [2] ~ series(3..500, inc=2) {
if isPrime(i) and isPrime(sumDigits(i)) {
write "{{i:3}} "
cnt += 1
diff --git a/Task/Additive-primes/Scala/additive-primes.scala b/Task/Additive-primes/Scala/additive-primes.scala
new file mode 100644
index 0000000000..447bb9eabb
--- /dev/null
+++ b/Task/Additive-primes/Scala/additive-primes.scala
@@ -0,0 +1,26 @@
+def isPrime(n: Int): Boolean = {
+ @annotation.tailrec
+ def checkDivisor(d: Int): Boolean = {
+ if (d * d > n) true
+ else if (n % d == 0) false
+ else checkDivisor(d + 2)
+ }
+
+ if (n < 2) false
+ else if (n == 2 || n == 3) true
+ else if (n % 2 == 0 || n % 3 == 0) false
+ else checkDivisor(5)
+}
+
+private def digitSum(n: Int): Int = n.toString.map(_ - '0').sum
+
+private def additivePrime(n: Int): Boolean = isPrime(n) && isPrime(digitSum(n))
+
+private def testAdditivePrime(max: Int): Unit = {
+ val result = (2 to max).filter(additivePrime)
+ println(result.mkString(", "))
+ println(s"Found ${result.length} additive primes less than 500.")
+}
+
+@main def main(): Unit =
+ testAdditivePrime(500)
diff --git a/Task/Address-of-a-variable/Zig/address-of-a-variable.zig b/Task/Address-of-a-variable/Zig/address-of-a-variable.zig
index 88fd6ff5ee..9012f0e79e 100644
--- a/Task/Address-of-a-variable/Zig/address-of-a-variable.zig
+++ b/Task/Address-of-a-variable/Zig/address-of-a-variable.zig
@@ -2,8 +2,9 @@ const std = @import("std");
pub fn main() !void {
const stdout = std.io.getStdOut().writer();
- var i: i32 = undefined;
- var address_of_i: *i32 = &i;
-
- try stdout.print("{x}\n", .{@intFromPtr(address_of_i)});
+ const i: i32 = 76;
+ try stdout.print("{x} {*}\n", .{
+ @intFromPtr(&i),
+ &i
+ });
}
diff --git a/Task/Align-columns/8080-Assembly/align-columns.8080 b/Task/Align-columns/8080-Assembly/align-columns.8080
new file mode 100644
index 0000000000..2156a3485e
--- /dev/null
+++ b/Task/Align-columns/8080-Assembly/align-columns.8080
@@ -0,0 +1,212 @@
+putc equ 2
+puts equ 9
+fopen equ 15
+fclose equ 16
+fread equ 20
+FCB1 equ 5Ch
+FCB2 equ 6Ch
+DTA equ 80h
+COLSEP equ '$'
+ org 100h
+
+ ;;; Check arguments
+ lxi d,argmsg
+ lda FCB1+1 ; Check file argument
+ cpi ' '
+ jz prmsg
+ lda FCB2+1 ; Check alignment argument
+ cpi 'L'
+ jz setal
+ cpi 'R'
+ jz setar
+ cpi 'C'
+ jnz prmsg
+ lxi h,center ; Set alignment function to run
+ jmp setfn
+setal: lxi h,left
+ jmp setfn
+setar: lxi h,right
+setfn: shld alnfn+1
+
+ ;;; Initialize column lengths to 0
+ xra a
+ lxi h,colw
+inicol: mov m,a
+ inr l
+ jnz inicol
+
+ ;;; Open file
+ lxi d,FCB1
+ mvi c,fopen
+ call 5
+ inr a
+ jz efile ; FF = error
+
+ ;;; Process file
+ lxi h,maxw ; Find maximum widths
+ call rdlins
+ lxi h,alnlin ; Read lines and align columns
+ call rdlins
+
+ ;;; Close file
+ lxi d,FCB1
+ mvi c,fclose
+ jmp 5
+
+ ;;; Update maximum widths of columns, given line
+maxw: lxi h,colw ; Column widths
+ lxi d,linbuf
+mcol: mvi b,0FFh ; B = column width
+mscan: inr b
+ ldax d ; Get current item
+ inx d ; Next item
+ call colend ; End of column?
+ jc mscan
+ push psw ; Keep column comparison
+ mov a,m ; Current width
+ cmp b ; Compare to new width
+ jnc mnxcol
+ mov m,b ; New one is bigger
+mnxcol: inr l ; Next column
+ pop psw ; Restore column comparison
+ jz mcol ; Keep going if not end of line
+ ret
+
+ ;;; Align and print columns of line
+alnlin: lxi h,colw
+ lxi b,linbuf
+alncol: lxi d,colbuf-1
+alnscn: inx d ; Copy current column to buffer
+ ldax b
+ stax d
+ inx b
+ call colend
+ jc alnscn
+ push psw
+ push h
+ push b
+alncal: xra a ; Zero-terminate the buffer
+ stax d
+ mov a,m ; Current max column length
+ sub e ; Minus length of this column
+ mov b,a ; Set B = current padding needed
+alnfn: call 0 ; Call selected alignment
+ pop b
+ pop h
+ inr l
+ pop psw
+ jz alncol ; Next column, if any
+ lxi d,newlin ; End line
+ mvi c,puts
+ jmp 5
+
+ ;;; Align column left and print
+left: push b ; Save padding needed
+ lxi h,colbuf ; Print column
+ call print0
+ pop b ; Restore padding
+ inr b ; Plus one, for separator between columns
+
+ ;;; Print B spaces as padding
+pad: xra a
+ ora b
+ rz ; No padding
+padl: push b
+ mvi e,' '
+ mvi c,putc
+ call 5
+ pop b
+ dcr b
+ jnz padl
+ ret
+
+ ;;; Align column right and print
+right: call pad ; Padding first
+ lxi h,colbuf
+ call print0 ; Then column
+ mvi b,1
+ jmp pad ; Separator space
+
+ ;;; Align column in the center and print
+center: mov a,b ; Split padding in half
+ rar
+ mov b,a
+ aci 0
+ mov c,a
+ push b ; Keep both parts
+ call pad ; Left padding
+ lxi h,colbuf ; Print column
+ call print0
+ pop b ; Restore padding
+ mov b,c ; Right padding
+ inr b ; Plus one for the separator
+ jmp pad
+
+ ;;; Print 0-terminated string at HL
+print0: mov a,m
+ ana a
+ rz
+ push h
+ mov e,m
+ mvi c,putc
+ call 5
+ pop h
+ inx h
+ jmp print0
+
+ ;;; Does character in A end a column?
+ ;;; C clear if so. Z clear if also end of line.
+colend: cpi 32 ; End of line?
+ cmc
+ rnc
+ cpi COLSEP ; Separator?
+ rz
+ stc ; If neither, set carry and return
+ ret
+
+ ;;; Process file in FCB1 line by line
+ ;;; HL = line callback
+rdlins: shld linecb+1 ; Set callback
+ xra a ; Start at beginning of file
+ sta FCB1+0Ch ; EX
+ sta FCB1+0Eh ; S2
+ sta FCB1+0Fh ; RC
+ sta FCB1+20h ; AL
+ lxi d,linbuf ; Start write pointer at line buffer
+rdrec: push d ; Keep write pointer
+ lxi d,FCB1 ; Read next record
+ mvi c,fread
+ call 5
+ pop d ; Restore write pointer
+ dcr a ; 1 = EOF
+ rz
+ inr a
+ jnz efile ; Otherwise, <>0 = error
+ lxi h,DTA ; Reset read pointer to DTA
+cpydat: mov a,m ; Copy byte to line buffer
+ stax d
+ inx d
+ cpi 26 ; EOF -> done
+ rz
+ cpi 10 ; (\r)\n -> EOL
+ jnz cnexb
+ push h ; Keep record pointer
+linecb: call 0 ; Call callback routine
+ pop h ; Restore record pointer
+ lxi d,linbuf ; Reset line pointer
+cnexb: inr l ; Next byte
+ jz rdrec ; Next record
+ jmp cpydat
+efile: lxi d,filerr
+prmsg: mvi c,puts
+ jmp 5
+
+ ;;; Messages
+argmsg: db 'ALIGN FILE.TXT L/R/C$'
+filerr: db 'FILE ERROR$'
+newlin: db 13,10,'$'
+
+ ;;; Variables
+colw equ ($/256+1)*256 ; Column widths (page-aligned)
+colbuf equ colw+256 ; Column buffer
+linbuf equ colbuf+256 ; Line buffer
diff --git a/Task/Align-columns/Cowgol/align-columns.cowgol b/Task/Align-columns/Cowgol/align-columns.cowgol
new file mode 100644
index 0000000000..67428f2a4f
--- /dev/null
+++ b/Task/Align-columns/Cowgol/align-columns.cowgol
@@ -0,0 +1,134 @@
+include "cowgol.coh";
+include "strings.coh";
+include "file.coh";
+include "argv.coh";
+
+interface ColumnCb(colnum: uint8, col: [uint8], isLast: uint8);
+sub ForEachColumn(fcb: [FCB], colfn: ColumnCb, colsep: uint8) is
+ var linebuf: uint8[256];
+ var bufptr := &linebuf[0];
+
+ sub HandleColumns() is
+ var colbuf: uint8[256];
+ var col: uint8 := 0;
+ var lineptr := &linebuf[0];
+ var colptr := &colbuf[0];
+
+ while [lineptr] != 0 loop
+ if [lineptr] == colsep or [lineptr] == '\n' then
+ [colptr] := 0;
+ colptr := &colbuf[0];
+ if [lineptr] == '\n' then
+ colfn(col, colptr, 1);
+ else
+ colfn(col, colptr, 0);
+ end if;
+ col := col + 1;
+ else
+ [colptr] := [lineptr];
+ colptr := @next colptr;
+ end if;
+ lineptr := @next lineptr;
+ end loop;
+ end sub;
+
+ var len := FCBExt(fcb);
+ FCBSeek(fcb, 0);
+
+ while len > 0 loop
+ var ch := FCBGetChar(fcb);
+ [bufptr] := ch;
+ bufptr := @next bufptr;
+ len := len - 1;
+
+ if ch == '\n' then
+ [bufptr] := 0;
+ HandleColumns();
+ bufptr := &linebuf[0];
+ end if;
+ end loop;
+end sub;
+
+var columnWidths: uint8[256];
+sub FindColumnMaxWidths(fcb: [FCB], colsep: uint8) is
+ sub FindColumnMaxWidth implements ColumnCb is
+ var len := StrLen(col) as uint8;
+ if columnWidths[colnum] < len then
+ columnWidths[colnum] := len;
+ end if;
+ end sub;
+
+ ForEachColumn(fcb, FindColumnMaxWidth, colsep);
+end sub;
+
+sub Pad(padding: uint8) is
+ while padding > 0 loop
+ print_char(' ');
+ padding := padding - 1;
+ end loop;
+end sub;
+
+interface Alignment(padding: uint8, string: [uint8]);
+sub Left implements Alignment is
+ print(string);
+ Pad(padding);
+end sub;
+
+sub Right implements Alignment is
+ Pad(padding);
+ print(string);
+end sub;
+
+sub Center implements Alignment is
+ Pad(padding >> 1);
+ print(string);
+ Pad((padding >> 1) + (padding & 1));
+end sub;
+
+sub PrintColumnsAligned(fcb: [FCB], colsep: uint8, alignment: Alignment) is
+ sub PrintColumnAligned implements ColumnCb is
+ var len := StrLen(col) as uint8;
+ var padding := columnWidths[colnum] - len;
+ alignment(padding, col);
+ if isLast != 0 then
+ print_nl();
+ else
+ print_char(' ');
+ end if;
+ end sub;
+
+ ForEachColumn(fcb, PrintColumnAligned, colsep);
+end sub;
+
+ArgvInit();
+var filename := ArgvNext();
+if filename == 0 as [uint8] then
+ print("No filename given\n");
+ ExitWithError();
+end if;
+
+var align := ArgvNext();
+if align == 0 as [uint8] then
+ print("No alignment given\n");
+ ExitWithError();
+end if;
+
+var alignment: Alignment;
+case [align] & ~32 is
+ when 'L': alignment := Left;
+ when 'R': alignment := Right;
+ when 'C': alignment := Center;
+ when else:
+ print("Alignment must be L(eft), R(ight), or C(enter)\n");
+ ExitWithError();
+end case;
+
+var file: FCB;
+if FCBOpenIn(&file, filename) != 0 then
+ print("Cannot open file\n");
+ ExitWithError();
+end if;
+
+const separator := '$';
+FindColumnMaxWidths(&file, separator);
+PrintColumnsAligned(&file, separator, alignment);
diff --git a/Task/Align-columns/Draco/align-columns.draco b/Task/Align-columns/Draco/align-columns.draco
new file mode 100644
index 0000000000..3c5cfe9a9a
--- /dev/null
+++ b/Task/Align-columns/Draco/align-columns.draco
@@ -0,0 +1,93 @@
+\util.g
+char separator = '$';
+
+type
+ colHandler = proc(byte n; *char col; bool last)void,
+ alignment = proc(byte padding; *char col)void;
+
+[256]byte ColWidths;
+alignment Alignment;
+
+proc find_max_col_width(byte n; *char col; bool last) void:
+ if ColWidths[n] < CharsLen(col) then
+ ColWidths[n] := CharsLen(col)
+ fi
+corp
+
+proc write_col_aligned(byte n; *char col; bool last) void:
+ byte padding;
+ padding := ColWidths[n] - CharsLen(col);
+ Alignment(padding, col);
+ if last then writeln() else write(' ') fi
+corp
+
+proc pad(byte padding) void:
+ while padding>0 do write(' '); padding := padding-1 od
+corp
+
+proc align_left(byte padding; *char col) void: write(col); pad(padding) corp
+proc align_right(byte padding; *char col) void: pad(padding); write(col) corp
+proc align_center(byte padding; *char col) void:
+ pad(padding>>1);
+ write(col);
+ pad((padding>>1) + (padding&1))
+corp
+
+proc do_line(*char line; colHandler handler) void:
+ byte col;
+ bool last;
+ char ch;
+ *char colstart;
+ col := 0;
+ colstart := line;
+
+ while
+ ch := line*;
+ last := ch = '\e';
+ if last or ch = separator then
+ line* := '\e';
+ handler(col, colstart, last);
+ colstart := line+1;
+ col := col+1
+ fi;
+ not last
+ do
+ line := line+1
+ od
+corp
+
+proc do_columns(*char filename; colHandler handler) void:
+ [256]char linebuf;
+ *char line;
+ channel input text in;
+ file(1024) infile;
+
+ open(in, infile, filename);
+ line := &linebuf[0];
+ while readln(in; line) do do_line(line, handler) od;
+ close(in);
+corp
+
+proc ucase(char c) char: pretend(pretend(c, byte) & ~32, char) corp
+
+proc main() void:
+ *char filename, align;
+ word i;
+ for i from 0 upto 255 do ColWidths[i] := 0 od;
+
+ filename := GetPar();
+ if filename = nil then writeln("No filename given"); exit(1) fi;
+
+ align := GetPar();
+ if align = nil then writeln("No alignment given"); exit(1) fi;
+
+ case ucase(align*)
+ incase 'L': Alignment := align_left
+ incase 'R': Alignment := align_right
+ incase 'C': Alignment := align_center
+ default: writeln("Alignment must be L/R/C"); exit(1)
+ esac;
+
+ do_columns(filename, find_max_col_width);
+ do_columns(filename, write_col_aligned)
+corp
diff --git a/Task/Align-columns/Emacs-Lisp/align-columns.l b/Task/Align-columns/Emacs-Lisp/align-columns.l
new file mode 100644
index 0000000000..a073ab13c1
--- /dev/null
+++ b/Task/Align-columns/Emacs-Lisp/align-columns.l
@@ -0,0 +1,251 @@
+(defun rob-even-p (integer)
+ "Test if INTEGER is even."
+ (= (% integer 2) 0))
+
+(defun rob-odd-p (integer)
+ "Test if INTEGER is odd."
+ (not (rob-even-p integer)))
+
+(defun both-odd-or-both-even-p (x y)
+ "Test if X and Y are both even or both odd."
+ (or (and (rob-even-p x) (rob-even-p y))
+ (and (rob-odd-p x) (rob-odd-p y))))
+
+(defun word-lengths (words)
+ "Convert WORDS into list of lengths of each word."
+ (mapcar 'length words))
+
+(defun get-one-row (row-number rows-columns-words)
+ "Get ROW-NUMBER row from ROWS-COLUMNS-WORDS.
+ROWS-COLUMNS-WORDS is list of lists in form of row, column, word."
+ (seq-filter
+ (lambda (element)
+ (= row-number (car element)))
+ rows-columns-words))
+
+(defun get-one-word (row-number column-number rows-columns-words)
+ "Get one word from ROWS-COLUMNS-WORDS at ROW-NUMBER and COLUMN-NUMBER.
+ROWS-COLUMNS-WORDS is list of lists in form of row, column, word."
+ (delq nil
+ (mapcar
+ (lambda (element)
+ (when (= column-number (nth 1 element))
+ (nth 2 element)))
+ (get-one-row row-number rows-columns-words))))
+
+(defun get-last-row (rows-columns-words)
+ "Get the number of the last row of ROWS-COLUMNS-WORDS.
+ROWS-COLUMNS-WORDS is a list of lists, each list in the form of
+row, column, word."
+ (apply 'max (mapcar 'car rows-columns-words)))
+
+(defun list-nth-column (column rows-columns-words)
+ "List the words in column COLUMN of ROWS-COLUMNS-WORDS.
+ROWS-COLUMNS-WORDS is a list of lists, each list in the form of row, column,
+word."
+ (let ((row 1)
+ (column-word)
+ (last-row (get-last-row rows-columns-words ))
+ (matches nil))
+ (while (and (<= row last-row)
+ (<= column (get-last-column rows-columns-words)))
+ (setq column-word (get-one-word row column rows-columns-words))
+ (when (null column-word)
+ (setq column-word ""))
+ (push column-word matches)
+ (setq row (1+ row)))
+ (flatten-tree (nreverse matches))))
+
+(defun get-widest-in-column (column)
+ "Get the widest word in COLUMN, which is a list of words."
+ (apply #'max (word-lengths column)))
+
+(defun get-column-width (column)
+ "Calculate the width of COLUMN, which is a list of words."
+ (+ (get-widest-in-column column) 2))
+
+(defun get-column-widths (rows-columns-words)
+ "Make a list of the column widths in ROWS-COLUMNS-WORDS.
+ROWS-COLUMNS-WORDS is list of lists, with each list in the form of row, column,
+word."
+ (let ((last-column (get-last-column rows-columns-words))
+ (column 1)
+ (columns))
+ (while (<= column last-column)
+ (push (get-column-width (list-nth-column column rows-columns-words)) columns)
+ (setq column (1+ column)))
+ (reverse columns)))
+
+(defun add-column-widths (widths rows-columns-words)
+ "Add WIDTHS to ROWS-COLUMNS-WORDS.
+ROWS-COLUMNS-WORDS is a list of lists, with each list in the form of row,
+column, word. WIDTHS are the widths of each column. Output is a
+list of lists, with each list in the form of column-width, row,
+column, word."
+ (let ((new-data)
+ (new-database)
+ (column)
+ (width))
+ (dolist (data rows-columns-words)
+ (setq column (cadr data))
+ (setq width (nth (- column 1) widths))
+ (setq new-data (push width data))
+ (push new-data new-database))
+ (nreverse new-database)))
+
+(defun get-last-column (rows-columns-words)
+ "Get the number of the last column in ROWS-COLUMNS-WORDS."
+ (apply 'max (mapcar 'cadr rows-columns-words)))
+
+(defun create-rows-columns-words ()
+ "Put text from column-data.txt file in lists.
+Each list consists of a row number, a column number, and a word."
+ (let ((lines)
+ (line-number 0)
+ (word-number)
+ (words))
+ (with-temp-buffer
+ (insert-file-contents "~/Documents/Elisp/column_data.txt")
+ (beginning-of-buffer)
+ (dolist (line (split-string (buffer-string) "[\r\n]" :no-nulls))
+ (push line lines))
+ (setq lines (nreverse lines)))
+ (dolist (line lines)
+ (setq line-number (1+ line-number))
+ (setq word-number 0)
+ (dolist (word (split-string line "\\$" :no-nulls))
+ (setq word-number (1+ word-number))
+ (push (list line-number word-number word) words)))
+ (setq words (nreverse words))))
+
+(defun pad-for-center-align (column-width text)
+ "Pad TEXT to center in space of COLUMN-WIDTH."
+ (let* ((text-width (length text))
+ (total-padding-length (- column-width text-width))
+ (pre-padding-length)
+ (post-padding-length)
+ (pre-padding)
+ (post-padding))
+ (if (both-odd-or-both-even-p text-width column-width)
+ (progn
+ (setq pre-padding-length (/ total-padding-length 2))
+ (setq post-padding-length pre-padding-length))
+ (setq pre-padding-length (+ (/ total-padding-length 2) 1))
+ (setq post-padding-length (- pre-padding-length 1)))
+ (setq pre-padding (make-string pre-padding-length ? ))
+ (setq post-padding (make-string post-padding-length ? ))
+ (format "%s%s%s" pre-padding text post-padding)))
+
+(defun create-a-center-aligned-line (widths-1row-columns-words)
+ "Create a centered line based on WIDTHS-1ROW-COLUMNS-WORDS.
+WIDTHS-1ROW-COLUMNS-WORDS is a list of lists. Each list consists
+of the column-width, the row number, the column number, and the
+word. The row number is the same in all lists."
+ (let ((full-line "")
+ (next-section))
+ (insert "\n")
+ (dolist (word-data widths-1row-columns-words)
+ ;; below, nth 0 is the column width, nth 3 is the word
+ (setq next-section (pad-for-center-align (nth 0 word-data) (nth 3 word-data)))
+ (setq full-line (concat full-line next-section)))
+ (insert full-line)))
+
+(defun pad-for-left-align (column-width text)
+ "Pad TEXT to left-align in space of COLUMN-WIDTH."
+ (let* ((text-width (length text))
+ (post-padding-length (- column-width text-width)))
+ (setq post-padding (make-string post-padding-length ? ))
+ (format "%s%s" text post-padding)))
+
+(defun create-a-left-aligned-line (widths-1row-columns-words)
+ "Create a left-aligned line based on WIDTHS-1ROW-COLUMNS-WORDS.
+Each element of WIDTHS-1ROW-COLUMNS-WORDS consists of the column
+width, the row number, the column number, and the word. The row
+number is the same in every case."
+ (let ((full-line "")
+ (next-section))
+ (insert "\n")
+ (dolist (one-item widths-1row-columns-words)
+ (setq next-section (pad-for-left-align (nth 0 one-item) (nth 3 one-item)))
+ (setq full-line (concat full-line next-section)))
+ (insert full-line)))
+
+(defun pad-for-right-align (column-width text)
+ "Pad TEXT to right-align in space of COLUMN-WIDTH."
+ (let* ((text-width (length text))
+ (pre-padding-length (- column-width text-width)))
+ (setq pre-padding (make-string pre-padding-length ? ))
+ (format "%s%s" pre-padding text)))
+
+(defun create-a-right-aligned-line (widths-1row-columns-words)
+ "Create a right-aligned line based on WIDTHS-1ROW-COLUMNS-WORDS.
+Each element of WIDTHS-1ROW-COLUMNS-WORDS consists of the column
+width, the row number, the column number, and the word. The row
+number is the same in every case."
+ (let ((full-line "")
+ (next-section))
+ (insert "\n")
+ (dolist (one-item widths-1row-columns-words)
+ (setq next-section (pad-for-right-align (nth 0 one-item) (nth 3 one-item)))
+ (setq full-line (concat full-line next-section)))
+ (insert full-line)))
+
+(defun left-align-lines (rows-columns-words)
+ "Write ROWS-COLUMNS-WORDS in left-aligned columns.
+ROWS-COLUMNS-WORDS is a list of lists. Each list consists of the
+row number, the column number, and the word."
+ (let* ((row-number 1)
+ (column-widths (get-column-widths rows-columns-words))
+ (last-row (get-last-row rows-columns-words))
+ (one-row)
+ (width-place 0))
+ (while (<= row-number last-row)
+ (setq one-row (get-one-row row-number rows-columns-words))
+ (setq one-row (add-column-widths column-widths one-row))
+ (create-a-left-aligned-line one-row)
+ (setq row-number (1+ row-number))
+ (setq width-place (1+ width-place)))))
+
+(defun right-align-lines (rows-columns-words)
+ "Write ROWS-COLUMNS-WORDS in right-aligned columns.
+ROWS-COLUMNS-WORDS is a list of lists. Each list consists of the
+row number, the column number, and the word."
+ (let* ((row-number 1)
+ (column-widths (get-column-widths rows-columns-words))
+ (last-row (get-last-row rows-columns-words))
+ (one-row)
+ (width-place 0))
+ (while (<= row-number last-row)
+ (setq one-row (get-one-row row-number rows-columns-words))
+ (setq one-row (add-column-widths column-widths one-row))
+ (create-a-right-aligned-line one-row)
+ (setq row-number (1+ row-number))
+ (setq width-place (1+ width-place)))))
+
+(defun center-align-lines (rows-columns-words)
+ "Write ROWS-COLUMNS-WORDS in center-aligned columns.
+ROWS-COLUMNS-WORDS is a list of lists. Each list consists of the
+row number, the column number, and the word."
+ (let* ((row-number 1)
+ (column-widths (get-column-widths rows-columns-words))
+ (last-row (get-last-row rows-columns-words))
+ (one-row)
+ (width-place 0))
+ (while (<= row-number last-row)
+ (setq one-row (get-one-row row-number rows-columns-words))
+ (setq one-row (add-column-widths column-widths one-row))
+ (create-a-center-aligned-line one-row)
+ (setq row-number (1+ row-number))
+ (setq width-place (1+ width-place)))))
+
+(defun align-lines (alignment rows-columns-words)
+ "Write ROWS-COLUMNS-WIDTHS with given ALIGNMENT.
+ROWS-COLUMNS-WIDTHS consists of a list of lists. Each internal list contains width of column, row number, column number, and a word."
+ (let ((align-function (pcase alignment
+ ('left 'left-align-lines)
+ ("left" 'left-align-lines)
+ ('center 'center-align-lines)
+ ("center" 'center-align-lines)
+ ('right 'right-align-lines)
+ ("right" 'right-align-lines))))
+ (funcall align-function rows-columns-words)))
diff --git a/Task/Align-columns/Miranda/align-columns.miranda b/Task/Align-columns/Miranda/align-columns.miranda
new file mode 100644
index 0000000000..f39cb05be0
--- /dev/null
+++ b/Task/Align-columns/Miranda/align-columns.miranda
@@ -0,0 +1,34 @@
+#! /usr/bin/mira -exec
+main :: [sys_message]
+main = [Stdout (align (alignment algm) '$' (read file))]
+ where [cmd, file, algm] = $*
+
+alignment :: [char]->num->[char]->[char]
+alignment "left" = ljustify
+alignment "center" = cjustify
+alignment "right" = rjustify
+alignment x = error "Alignment must be left, center, or right"
+
+align :: (num->[char]->[char])->char->[char]->[char]
+align just sep text = (lay . map (alignline just sep cols) . lines) text
+ where cols = colwidths sep text
+
+split :: *->[*]->[[*]]
+split sep = s []
+ where s acc [] = [acc]
+ s acc (a:as) = acc:s [] as, if a==sep
+ = s (acc++[a]) as, otherwise
+
+colwidths :: char->[char]->[num]
+colwidths sep text = (map max . transpose . map (extend maxwidth 0)) widths
+ where widths = map (map (#) . split sep) (lines text)
+ maxwidth = max (map (#) widths)
+
+alignline :: (num->[char]->[char])->char->[num]->[char]->[char]
+alignline just sep cols = concat . map (++" ") . zipwith just cols . split sep
+
+zipwith :: (*->**->***)->[*]->[**]->[***]
+zipwith f xs ys = map f' (zip2 xs ys) where f' (x,y) = f x y
+
+extend :: num->*->[*]->[*]
+extend n k ls = ls ++ take (n-#ls) (repeat k)
diff --git a/Task/Align-columns/Refal/align-columns.refal b/Task/Align-columns/Refal/align-columns.refal
new file mode 100644
index 0000000000..19662f46b2
--- /dev/null
+++ b/Task/Align-columns/Refal/align-columns.refal
@@ -0,0 +1,71 @@
+$ENTRY Go {
+ , : e.File
+ , : e.Alignment
+ , : e.Lines
+ , : e.Parts
+ , >: e.Cols
+ = ;
+};
+
+ReadFile {
+ s.Chan e.File =
+ ;
+ (s.Chan), : {
+ 0 = ;
+ e.Line = (e.Line) ;
+ };
+};
+
+Split {
+ (e.Sep) e.Part e.Sep e.Rest = (e.Part) ;
+ (e.Sep) e.Part = (e.Part);
+};
+
+Each {
+ (e.F) = ;
+ (e.F) (e.X) e.Xs = () ;
+};
+
+MaxWidth {
+ (Acc s.W) = s.W;
+ (Acc s.W) (e.P) e.X, : s.L, : {
+ '+' = ;
+ s.C = ;
+ };
+ e.X = ;
+};
+
+Transpose {
+ e.X, : e.L, : {
+ True = ;
+ False = (e.L) >;
+ };
+};
+
+ZipWith {
+ (e.F) () e.Ys = ;
+ (e.F) e.Xs () = ;
+ (e.F) (t.X e.Xs) (t.Y e.Ys) = ;
+};
+
+AlignCell {
+ ('left') (e.Cell) (s.Width),
+ : s.L = e.Cell ' '> ' ';
+ ('right') (e.Cell) (s.Width),
+ : s.L = ' '> e.Cell ' ';
+ ('center') (e.Cell) (s.Width),
+ > 2>: (s.P) s.V,
+ : e.LP,
+ ' '>: e.RP = e.LP e.Cell e.RP ' ';
+};
+
+AlignLine {
+ (e.Alignment) (e.Cols) e.Line =
+ >;
+};
+
+Rep { 0 s.C = ; s.N s.C = s.C s.C>; };
+Empty { = True; () e.X = ; e.X = False; };
+Len { e.X, : s.L e.X = s.L; };
+Head { = ; (e.X) e.Xs = e.X; };
+Tail { = ; (e.X) e.Xs = e.Xs; };
diff --git a/Task/Aliquot-sequence-classifications/FutureBasic/aliquot-sequence-classifications.basic b/Task/Aliquot-sequence-classifications/FutureBasic/aliquot-sequence-classifications.basic
new file mode 100644
index 0000000000..663c14ccfa
--- /dev/null
+++ b/Task/Aliquot-sequence-classifications/FutureBasic/aliquot-sequence-classifications.basic
@@ -0,0 +1,95 @@
+begin globals
+ short n
+ long arr(17)
+ bool gStop = _False
+end globals
+
+local fn sumFactors(nx as long) as long
+ long i, sumFactor
+ sumFactor = 0
+ for i = 1 to fix(nx / 2)
+ if (nx) mod i = 0 then sumFactor = sumFactor + i
+ next
+end fn = sumFactor
+
+void local fn printSeries(arrx as short, size as short, type as str255)
+ short i = 0
+ print
+ print "Integer" + str$(arrx) + ", Type: " + type + ", Series: ";
+ for i=0 to size - 2
+ print str$(arr(i)) + " ";
+ next i
+end fn
+
+local fn Aliquot(nx as long)
+
+ short i, j
+ str255 type
+
+ type = "Sociable"
+ arr(0) = nx
+
+ for i = 1 to 15
+
+ arr(i) = fn sumFactors(arr(i-1))
+ if (arr(i)=0 || arr(i)=nx || (arr(i) = arr(i-1)) && arr(i)<>nx)
+ if arr(i) = 0
+ type = "Terminating"
+ else
+ if arr(i) = nx && i = 1
+ type = "Perfect"
+ else
+ if arr(i) = nx && i = 2
+ type = "Amicable"
+ else
+ if arr(i) = arr(i-1) && arr(i)<>nx
+ type = "Aspiring"
+ end if
+ end if
+ end if
+ end if
+
+ fn printSeries(arr(0),i+1,type)
+ if type = "Terminating"
+ print " 0"
+ else
+ print
+ end if
+
+ exit fn
+ end if
+
+
+ for j = 1 to i-1
+ if arr(j) = arr(i)
+ fn printSeries(arr(0),i+1,"Cyclic")
+ print
+ exit fn
+ end if
+ next j
+ next i
+ fn printSeries(arr(i),i+1,"Non-Terminating")
+ print
+
+end fn
+
+
+local fn DoAliquot
+ // declare and assign c-type array
+ long dataArray(30) = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 28, 496, 220, 1184,¬
+ 12496, 1264460, 790, 909, 562, 1064, 1488, 0}
+
+ short i
+ for i = 0 to 24
+ if dataArray(i) = 0 then gStop = _True:exit fn
+ fn Aliquot(dataArray(i))
+ next i
+
+end fn = gStop
+
+window 1,@"Aliquot sequence classifications",fn CGRectMake(0, 0, 1150, 700)
+windowcenter(1)
+
+fn AppSetTimer( .000001, @Fn DoAliquot, _true )
+
+handleevents
diff --git a/Task/Almkvist-Giullera-formula-for-pi/PARI-GP/almkvist-giullera-formula-for-pi.parigp b/Task/Almkvist-Giullera-formula-for-pi/PARI-GP/almkvist-giullera-formula-for-pi.parigp
new file mode 100644
index 0000000000..9761b3ae9b
--- /dev/null
+++ b/Task/Almkvist-Giullera-formula-for-pi/PARI-GP/almkvist-giullera-formula-for-pi.parigp
@@ -0,0 +1,2 @@
+\p77
+sqrt(375/4/suminf(n=0,(6*n)!*(532*n^2+126*n+9.)/(n!*10^n)^6))
diff --git a/Task/Amb/Langur/amb.langur b/Task/Amb/Langur/amb.langur
index 3adeaad38f..7f047193bb 100644
--- a/Task/Amb/Langur/amb.langur
+++ b/Task/Amb/Langur/amb.langur
@@ -10,6 +10,6 @@ val alljoin = fn words: for[=true] i of len(words)-1 {
}
# amb expects 2 or more arguments
-val amb = fn ...[2..] words: if alljoin(words) { join " ", words }
+val amb = fn ...[2..] words: if alljoin(words) { join words, by=" " }
-writeln join("\n", filter(mapX(amb, wordsets...)))
+writeln join(mapX(wordsets..., by=amb) -> filter, by="\n")
diff --git a/Task/Amb/Scheme/amb-1.scm b/Task/Amb/Scheme/amb-1.scm
index 951db6f220..825f13342c 100644
--- a/Task/Amb/Scheme/amb-1.scm
+++ b/Task/Amb/Scheme/amb-1.scm
@@ -13,7 +13,7 @@
(LAMBDA (K-SUCCESS) ; which we return possibles.
(CALL-WITH-CURRENT-CONTINUATION
(LAMBDA (K-FAILURE) ; K-FAILURE will try the next
- (SET! FAIL K-FAILURE) ; possible expression.
+ (SET! FAIL (LAMBDA () (K-FAILURE 'anything-is-fine-here))) ; possible expression.
(K-SUCCESS ; Note that the expression is
(LAMBDA () ; evaluated in tail position
expression)))) ; with respect to AMB.
diff --git a/Task/Angle-difference-between-two-bearings/ANSI-BASIC/angle-difference-between-two-bearings.basic b/Task/Angle-difference-between-two-bearings/ANSI-BASIC/angle-difference-between-two-bearings.basic
new file mode 100644
index 0000000000..9a7c6b0d99
--- /dev/null
+++ b/Task/Angle-difference-between-two-bearings/ANSI-BASIC/angle-difference-between-two-bearings.basic
@@ -0,0 +1,33 @@
+100 REM Angle difference between two bearings
+110 DECLARE EXTERNAL FUNCTION GetDiff
+120 REM
+130 SUB PrintRow(B1, B2)
+140 PRINT USING "#######.###### #######.###### #######.######": B1, B2, GetDiff(B1, B2)
+150 END SUB
+160 REM
+170 print "Input in -180 to +180 range"
+180 PRINT " Bearing 1 Bearing 2 Difference"
+190 CALL PrintRow(20.0, 45.0)
+200 CALL PrintRow(-45.0, 45.0)
+210 CALL PrintRow(-85.0, 90.0)
+220 CALL PrintRow(-95.0, 90.0)
+230 CALL PrintRow(-45.0, 125.0)
+240 CALL PrintRow(-45.0, 145.0)
+250 CALL PrintRow(-45.0, 125.0)
+260 CALL PrintRow(-45.0, 145.0)
+270 CALL PrintRow(29.4803, -88.6381)
+280 CALL PrintRow(-78.3251, -159.036)
+290 PRINT
+300 PRINT "Input in wider range"
+310 PRINT " Bearing 1 Bearing 2 Difference"
+320 CALL PrintRow(-70099.74233810938, 29840.67437876723)
+330 CALL PrintRow(-165313.6666297357, 33693.9894517456)
+340 CALL PrintRow(1174.8380510598456, -154146.66490124757)
+350 CALL PrintRow(60175.77306795546, 42213.07192354373)
+360 END
+370 REM
+380 EXTERNAL FUNCTION GetDiff (B1, B2)
+390 LET R = MOD(B2 - B1, 360.0)
+400 IF R >= 180.0 THEN LET R = R - 360.0
+410 LET GetDiff = R
+420 END FUNCTION
diff --git a/Task/Angle-difference-between-two-bearings/C++/angle-difference-between-two-bearings.cpp b/Task/Angle-difference-between-two-bearings/C++/angle-difference-between-two-bearings.cpp
index af35a7815c..92cb3f68b7 100644
--- a/Task/Angle-difference-between-two-bearings/C++/angle-difference-between-two-bearings.cpp
+++ b/Task/Angle-difference-between-two-bearings/C++/angle-difference-between-two-bearings.cpp
@@ -2,34 +2,40 @@
#include
using namespace std;
-double getDifference(double b1, double b2) {
- double r = fmod(b2 - b1, 360.0);
- if (r < -180.0)
- r += 360.0;
- if (r >= 180.0)
- r -= 360.0;
- return r;
+double getDifference(double b1, double b2)
+{
+ double r = fmod(b2 - b1, 360.0);
+ if (r < -180.0)
+ r += 360.0;
+ if (r >= 180.0)
+ r -= 360.0;
+ return r;
+}
+
+inline void printRow(double b1, double b2)
+{
+ cout << getDifference(b1, b2) << endl;
}
int main()
{
- cout << "Input in -180 to +180 range" << endl;
- cout << getDifference(20.0, 45.0) << endl;
- cout << getDifference(-45.0, 45.0) << endl;
- cout << getDifference(-85.0, 90.0) << endl;
- cout << getDifference(-95.0, 90.0) << endl;
- cout << getDifference(-45.0, 125.0) << endl;
- cout << getDifference(-45.0, 145.0) << endl;
- cout << getDifference(-45.0, 125.0) << endl;
- cout << getDifference(-45.0, 145.0) << endl;
- cout << getDifference(29.4803, -88.6381) << endl;
- cout << getDifference(-78.3251, -159.036) << endl;
-
- cout << "Input in wider range" << endl;
- cout << getDifference(-70099.74233810938, 29840.67437876723) << endl;
- cout << getDifference(-165313.6666297357, 33693.9894517456) << endl;
- cout << getDifference(1174.8380510598456, -154146.66490124757) << endl;
- cout << getDifference(60175.77306795546, 42213.07192354373) << endl;
+ cout << "Input in -180 to +180 range" << endl;
+ printRow(20.0, 45.0);
+ printRow(-45.0, 45.0);
+ printRow(-85.0, 90.0);
+ printRow(-95.0, 90.0);
+ printRow(-45.0, 125.0);
+ printRow(-45.0, 145.0);
+ printRow(-45.0, 125.0);
+ printRow(-45.0, 145.0);
+ printRow(29.4803, -88.6381);
+ printRow(-78.3251, -159.036);
- return 0;
+ cout << endl << "Input in wider range" << endl;
+ printRow(-70099.74233810938, 29840.67437876723);
+ printRow(-165313.6666297357, 33693.9894517456);
+ printRow(1174.8380510598456, -154146.66490124757);
+ printRow(60175.77306795546, 42213.07192354373);
+
+ return 0;
}
diff --git a/Task/Angle-difference-between-two-bearings/PHP/angle-difference-between-two-bearings.php b/Task/Angle-difference-between-two-bearings/PHP/angle-difference-between-two-bearings.php
new file mode 100644
index 0000000000..0cec699805
--- /dev/null
+++ b/Task/Angle-difference-between-two-bearings/PHP/angle-difference-between-two-bearings.php
@@ -0,0 +1,38 @@
+ 180.0)
+ $r -= 360.0;
+ if ($r < -180.0)
+ $r += 360.0;
+ return $r;
+ }
+
+ function echo_row($b1, $b2) {
+ echo str_pad(number_format($b1, 6, ".", ""), 14, " ", STR_PAD_LEFT).' ';
+ echo str_pad(number_format($b2, 6, ".", ""), 14, " ", STR_PAD_LEFT).' ';
+ echo str_pad(number_format(get_diff($b1, $b2), 6), 14, " ", STR_PAD_LEFT);
+ echo "\n";
+ }
+
+ echo "Input in -180 to +180 range\n";
+ echo " Bearing 1 Bearing 2 Difference\n";
+ echo_row(20.0, 45.0);
+ echo_row(-45.0, 45.0);
+ echo_row(-85.0, 90.0);
+ echo_row(-95.0, 90.0);
+ echo_row(-45.0, 125.0);
+ echo_row(-45.0, 145.0);
+ echo_row(-45.0, 125.0);
+ echo_row(-45.0, 145.0);
+ echo_row(29.4803, -88.6381);
+ echo_row(-78.3251, -159.036);
+ echo "\nInput in wider range\n";
+ echo " Bearing 1 Bearing 2 Difference\n";
+ echo_row(-70099.74233810938, 29840.67437876723);
+ echo_row(-165313.6666297357, 33693.9894517456);
+ echo_row(1174.8380510598456, -154146.66490124757);
+ echo_row(60175.77306795546, 42213.07192354373);
+?>
diff --git a/Task/Angles-geometric-normalization-and-conversion/FutureBasic/angles-geometric-normalization-and-conversion.basic b/Task/Angles-geometric-normalization-and-conversion/FutureBasic/angles-geometric-normalization-and-conversion.basic
new file mode 100644
index 0000000000..df05b07e41
--- /dev/null
+++ b/Task/Angles-geometric-normalization-and-conversion/FutureBasic/angles-geometric-normalization-and-conversion.basic
@@ -0,0 +1,100 @@
+include "NSLog.incl"
+
+double local fn Normalize( f as double, n as double )
+ double a = f
+ while ( a < -n ) : a += n : wend
+ while ( a >= n ) : a -= n : wend
+end fn = a
+
+double local fn NormalizeToDegrees( f as double ) return fn Normalize( f, 360 ) end fn = 0.0
+double local fn NormalizeToGradians( f as double ) return fn Normalize( f, 400 ) end fn = 0.0
+double local fn NormalizeToMils( f as double ) return fn Normalize( f, 6400 ) end fn = 0.0
+double local fn NormalizeToRadians( f as double ) return fn Normalize( f, 2 * M_PI ) end fn = 0.0
+
+double local fn d2g( f as double ) return f * 10 / 9 end fn = 0.0
+double local fn d2m( f as double ) return f * 160 / 9 end fn = 0.0
+double local fn d2r( f as double ) return f * M_PI / 180 end fn = 0.0
+
+double local fn g2d( f as double ) return f * 9 / 10 end fn = 0.0
+double local fn g2m( f as double ) return f * 16 end fn = 0.0
+double local fn g2r( f as double ) return f * M_PI / 200 end fn = 0.0
+
+double local fn m2d( f as double ) return f * 9 / 160 end fn = 0.0
+double local fn m2g( f as double ) return f / 16 end fn = 0.0
+double local fn m2r( f as double ) return f * M_PI / 3200 end fn = 0.0
+
+double local fn r2d( f as double ) return f * 180 / M_PI end fn = 0.0
+double local fn r2g( f as double ) return f * 200 / M_PI end fn = 0.0
+double local fn r2m( f as double ) return f * 3200 / M_PI end fn = 0.0
+
+local fn CalculateDegrees
+ CFArrayRef angles = @[@-2, @-1, @0, @1, @2, @6.2831853, @16, @57.2957795, @359, @6399, @1000000]
+ double angle, degrees, gradians, mils, radians
+ NSUInteger i
+ CFStringRef unit
+ CFStringRef dashpad = fn StringByPaddingToLength( @"", 73, @"-", 0 )
+
+ ptr anglePtr = fn StringUTF8String( @"Angle" )
+ ptr unitPtr = fn StringUTF8String( @"Unit" )
+ ptr normalPtr = fn StringUTF8String( @"Normalized" )
+ ptr gradiansPtr = fn StringUTF8String( @"Gradians" )
+ ptr milsPtr = fn StringUTF8String( @"Mils" )
+ ptr radiansPtr = fn StringUTF8String( @"Radians" )
+
+ // Header
+ NSLog( @"\n%@", dashpad )
+ NSLog( @"%13s %5s %15s %10s %7s %15s", anglePtr, unitPtr, normalPtr, gradiansPtr, milsPtr, radiansPtr )
+ NSLog( @"%@", dashpad )
+
+ // Degrees
+ for i = 0 to fn ArrayCount( angles ) - 1
+ angle = dblval( angles[i] )
+ unit = @"Degrees"
+ degrees = fn NormalizeToDegrees( angle )
+ gradians = fn NormalizeToGradians( fn d2g( degrees ) )
+ mils = fn NormalizeToMils( fn d2m( degrees ) )
+ radians = fn NormalizeToRadians( fn d2r( degrees ) )
+ NSLog( @"%13.4f %-10s % -12.4f % -11.4f % -12.4f % -13.4f", angle, fn StringUTF8String( unit ), degrees, gradians, mils, radians )
+ next
+ NSLog( @"" )
+
+ // Gradians
+ for i = 0 to fn ArrayCount( angles ) - 1
+ angle = dblval( angles[i] )
+ unit = @"Gradians"
+ gradians = fn NormalizeToGradians( angle )
+ degrees = fn NormalizeToDegrees( fn g2d( gradians ) )
+ mils = fn NormalizeToMils( fn g2m( gradians ) )
+ radians = fn NormalizeToRadians( fn g2r( gradians ) )
+ NSLog( @"%13.4f %-10s % -12.4f % -11.4f % -12.4f % -13.4f", angle, fn StringUTF8String( unit ), degrees, gradians, mils, radians )
+ next
+ NSLog( @"" )
+
+ // Mils
+ for i = 0 to fn ArrayCount( angles ) - 1
+ angle = dblval( angles[i] )
+ unit = @"Mils"
+ mils = fn NormalizeToMils( angle )
+ degrees = fn NormalizeToDegrees( fn m2d( mils ) )
+ gradians = fn NormalizeToGradians( fn m2g( mils ) )
+ radians = fn NormalizeToRadians( fn m2r( mils ) )
+ NSLog( @"%13.4f %-10s % -12.4f % -11.4f % -12.4f % -13.4f", angle, fn StringUTF8String( unit ), degrees, gradians, mils, radians )
+ next
+ NSLog( @"" )
+
+ // Radians
+ for i = 0 to fn ArrayCount( angles ) - 1
+ angle = dblval( angles[i] )
+ unit = @"Radians"
+ radians = fn NormalizeToRadians( angle )
+ degrees = fn NormalizeToDegrees( fn r2d( radians ) )
+ gradians = fn NormalizeToGradians( fn r2g( radians ) )
+ mils = fn NormalizeToMils( fn r2m( radians ) )
+ NSLog( @"%13.4f %-10s % -12.4f % -11.4f % -12.4f % -13.4f", angle, fn StringUTF8String( unit ), degrees, gradians, mils, radians )
+ next
+ NSLog( @"%@", dashpad )
+end fn
+
+fn CalculateDegrees
+
+HandleEvents
diff --git a/Task/Animate-a-pendulum/Locomotive-Basic/animate-a-pendulum.basic b/Task/Animate-a-pendulum/Locomotive-Basic/animate-a-pendulum.basic
new file mode 100644
index 0000000000..151efccb41
--- /dev/null
+++ b/Task/Animate-a-pendulum/Locomotive-Basic/animate-a-pendulum.basic
@@ -0,0 +1,16 @@
+10 mode 1
+20 theta=pi/2
+30 g=9.81
+40 l=1
+50 sp=0 : px=320 : py=300 : bx=px : by=py
+100 move bx-4,by+4:graphics pen 0:tag:print chr$(231);:tagoff
+110 move px,py:draw bx,by
+120 bx=px+l*250*sin(theta)
+130 by=py+l*250*cos(theta)
+140 move bx-4,by+4:graphics pen 1:tag:print chr$(231);:tagoff
+150 move px,py:draw bx,by
+160 accel=g*sin(theta)/l/100
+170 sp=sp+accel/100
+180 theta=theta+sp
+190 frame
+200 goto 100
diff --git a/Task/Animate-a-pendulum/Nim/animate-a-pendulum-2.nim b/Task/Animate-a-pendulum/Nim/animate-a-pendulum-2.nim
index 106527b8c9..d21ca79c40 100644
--- a/Task/Animate-a-pendulum/Nim/animate-a-pendulum-2.nim
+++ b/Task/Animate-a-pendulum/Nim/animate-a-pendulum-2.nim
@@ -3,82 +3,74 @@
import math
import times
-import gintro/[gobject, gdk, gtk, gio, cairo]
-import gintro/glib except Pi
+import gtk2 except update
+import gdk2, glib2, cairo
type
# Description of the simulation.
- Simulation = ref object
- area: DrawingArea # Drawing area.
+ Simulation = object
+ area: PDrawingArea # Drawing area.
length: float # Pendulum length.
g: float # Gravity (should be positive).
time: Time # Current time.
theta0: float # initial angle.
- theta: float # Current angle.
+ theta: float # Current drawangle.
omega: float # Angular velocity = derivative of theta.
accel: float # Angular acceleration = derivative of omega.
e: float # Total energy.
-#---------------------------------------------------------------------------------------------------
-proc newSimulation(area: DrawingArea; length, g, theta0: float): Simulation {.noInit.} =
- ## Allocate and initialize the simulation object.
+proc initSimulation(area: PDrawingArea; length, g, theta0: float): Simulation {.noInit.} =
+ ## Initialize a simulation object.
- new(result)
- result.area = area
- result.length = length
- result.g = g
- result.time = getTime()
- result.theta0 = theta0
- result.theta = theta0
- result.omega = 0
- result.accel = -g / length * sin(theta0)
- result.e = g * length * (1 - cos(theta0)) # Total energy = potential energy when starting.
+ result = Simulation(
+ area: area, length: length, g: g, time: getTime(),
+ theta0: theta0, theta: theta0, omega: 0,
+ accel: -g / length * sin(theta0),
+ e: g * length * (1 - cos(theta0))) # Total energy = potential energy when starting.
-#---------------------------------------------------------------------------------------------------
template toFloat(dt: Duration): float = dt.inNanoseconds.float / 1e9
-#---------------------------------------------------------------------------------------------------
const Origin = (x: 320.0, y: 100.0) # Pivot coordinates.
const Scale = 300 # Coordinates scaling constant.
-proc draw(sim: Simulation; context: cairo.Context) =
+
+proc draw(sim: var Simulation; context: ptr Context) =
## Draw the pendulum.
- # Compute coordinates in drawing area.
+ # Compute coordinates in drawing draw.
let x = Origin.x + sin(sim.theta) * Scale
let y = Origin.y + cos(sim.theta) * Scale
- # Clear the region.
+ # Clear the region.draw
context.moveTo(0, 0)
- context.setSource(0.0, 0.0, 0.0)
+ context.setSourceRgb(0.0, 0.0, 0.0)
context.paint()
# Draw pendulum.
context.moveTo(Origin.x, Origin.y)
- context.setSource(0.3, 1.0, 0.3)
+ context.setSourceRgb(0.3, 1.0, 0.3)
context.lineTo(x, y)
context.stroke()
# Draw pivot.
- context.setSource(0.3, 0.3, 1.0)
+ context.setSourceRgb(0.3, 0.3, 1.0)
context.arc(Origin.x, Origin.y, 8, 0, 2 * Pi)
context.fill()
# Draw mass.
- context.setSource(1.0, 0.3, 0.3)
+ context.setSourceRgb(1.0, 0.3, 0.3)
context.arc(x, y, 8, 0, 2 * Pi)
context.fill()
-#---------------------------------------------------------------------------------------------------
-proc update(sim: Simulation): gboolean =
+proc update(sim: var Simulation): gboolean =
## Update the simulation state.
- # compute time interval.
+ # Compute time interval.
let nextTime = getTime()
let dt = (nextTime - sim.time).toFloat
sim.time = nextTime
@@ -100,26 +92,25 @@ proc update(sim: Simulation): gboolean =
sim.draw(sim.area.window.cairoCreate())
-#---------------------------------------------------------------------------------------------------
-proc activate(app: Application) =
- ## Activate the application.
+proc onDestroyEvent(widget: PWidget; data: pointer): gboolean {.cdecl.} =
+ ## Quit the application.
+ mainQuit()
- let window = app.newApplicationWindow()
- window.setSizeRequest(640, 480)
- window.setTitle("Pendulum simulation")
- let area = newDrawingArea()
- window.add(area)
+nimInit()
- let sim = newSimulation(area, length = 5, g = 9.81, theta0 = PI / 3)
+let window = windowNew(WINDOW_TOPLEVEL)
+window.setSizeRequest(640, 480)
+window.setTitle("Pendulum simulation")
- timeoutAdd(10, update, sim)
+let area = drawingAreaNew()
+window.add area
+discard window.signalConnect("destroy", SIGNAL_FUNC(onDestroyEvent), nil)
- window.showAll()
+var sim = initSimulation(area, length = 5, g = 9.81, theta0 = PI / 3)
-#———————————————————————————————————————————————————————————————————————————————————————————————————
+discard timeoutAdd(10, cast[gtk2.TFunction](update), sim.addr)
-let app = newApplication(Application, "Rosetta.pendulum")
-discard app.connect("activate", activate)
-discard app.run()
+window.showAll()
+main()
diff --git a/Task/Animation/EasyLang/animation.easy b/Task/Animation/EasyLang/animation.easy
index 93d6d938cc..82c5470808 100644
--- a/Task/Animation/EasyLang/animation.easy
+++ b/Task/Animation/EasyLang/animation.easy
@@ -1,5 +1,5 @@
s$ = "Hello world! "
-textsize 16
+textsize 14
lg = len s$
on timer
color 333
@@ -7,13 +7,13 @@ on timer
rect 80 20
color 999
move 12 24
- text s$
- if forw = 0
+ text substr s$ 1 9
+ if forw = 1
s$ = substr s$ lg 1 & substr s$ 1 (lg - 1)
else
s$ = substr s$ 2 (lg - 1) & substr s$ 1 1
.
- timer 0.2
+ timer 0.4
.
on mouse_down
if mouse_x > 10 and mouse_x < 90
diff --git a/Task/Animation/Nim/animation.nim b/Task/Animation/Nim/animation.nim
index bb2821a478..bbb4e4ecce 100644
--- a/Task/Animation/Nim/animation.nim
+++ b/Task/Animation/Nim/animation.nim
@@ -1,4 +1,4 @@
-import gintro/[glib, gobject, gdk, gtk, gio]
+import gtk2, gdk2, glib2
type
@@ -6,56 +6,56 @@ type
ScrollDirection = enum toLeft, toRight
# Data transmitted to update callback.
- UpdateData = ref object
- label: Label
+ UpdateData = object
+ label: PLabel
scrollDir: ScrollDirection
-#---------------------------------------------------------------------------------------------------
-proc update(data: UpdateData): gboolean =
+proc update(data: var UpdateData): gboolean {.cdecl.} =
## Update the text, scrolling to the right or to the left according to "data.scrollDir".
-
- data.label.setText(if data.scrollDir == toRight: data.label.text[^1] & data.label.text[0..^2]
- else: data.label.text[1..^1] & data.label.text[0])
+ let text = $data.label.text # Get text as a Nim string.
+ let newText = if data.scrollDir == toRight: text[^1] & text[0..^2]
+ else: text[1..^1] & text[0]
+ data.label.setText(newText.cstring)
result = gboolean(1)
-#---------------------------------------------------------------------------------------------------
-proc changeScrollingDir(evtBox: EventBox; event: EventButton; data: UpdateData): bool =
+proc changeScrollingDir(evtBox: PEventBox; event: PEventButton; data: ptr UpdateData): bool =
## Change scrolling direction.
-
data.scrollDir = ScrollDirection(1 - ord(data.scrollDir))
-#---------------------------------------------------------------------------------------------------
-proc activate(app: Application) =
- ## Activate the application.
+proc onDestroyEvent(widget: PWidget; data: Pgpointer): gboolean {.cdecl.} =
+ ## Process the "destroy" event.
+ main_quit()
- let window = app.newApplicationWindow()
- window.setSizeRequest(150, 50)
- window.setTitle("Animation")
- # Create an event box to catch the button press event.
- let evtBox = newEventBox()
- window.add(evtBox)
- # Create the label and add it to the event box.
- let label = newLabel("Hello World! ")
- evtBox.add(label)
+nim_init()
- # Create the update data.
- let data = UpdateData(label: label, scrollDir: toRight)
+let window = window_new(WINDOW_TOPLEVEL)
+window.set_size_request(150, 50)
+window.set_title("Animation")
- # Connect the "button-press-event" to the callback to change scrolling direction.
- discard evtBox.connect("button-press-event", changeScrollingDir, data)
+# Create an event box to catch the button press event.
+let evtBox = event_box_new()
+window.add evtBox
- # Create a timer to update the label and simulate scrolling.
- timeoutAdd(200, update, data)
+# Create the label and add it to the event box.
+let label = label_new("Hello World! ")
+evtBox.add label
- window.showAll()
+# Create the update data.
+var data = UpdateData(label: label, scrollDir: toRight)
-#———————————————————————————————————————————————————————————————————————————————————————————————————
+# Connect the "button-press-event" to the callback to change the scrolling direction.
+discard evtBox.signal_connect("button-press-event", SIGNAL_FUNC(changeScrollingDir), data.addr)
-let app = newApplication(Application, "Rosetta.animation")
-discard app.connect("activate", activate)
-discard app.run()
+# Quit the application if the window is closed.
+discard window.signal_connect("destroy", SIGNAL_FUNC(onDestroyEvent), nil)
+
+# Create a timer to update the label and simulate scrolling.
+discard timeout_add(200, cast[gtk2.TFunction](animation.update), data.addr)
+
+window.showAll()
+main()
diff --git a/Task/Apply-a-callback-to-an-array/Langur/apply-a-callback-to-an-array.langur b/Task/Apply-a-callback-to-an-array/Langur/apply-a-callback-to-an-array.langur
index 67108b6065..61d90f3fb8 100644
--- a/Task/Apply-a-callback-to-an-array/Langur/apply-a-callback-to-an-array.langur
+++ b/Task/Apply-a-callback-to-an-array/Langur/apply-a-callback-to-an-array.langur
@@ -1 +1 @@
-writeln map(fn{^2}, 1..10)
+writeln map(1..10, by=fn{^2})
diff --git a/Task/Arbitrary-precision-integers-included-/Langur/arbitrary-precision-integers-included-.langur b/Task/Arbitrary-precision-integers-included-/Langur/arbitrary-precision-integers-included-.langur
index ac88ad929c..b7a153403f 100644
--- a/Task/Arbitrary-precision-integers-included-/Langur/arbitrary-precision-integers-included-.langur
+++ b/Task/Arbitrary-precision-integers-included-/Langur/arbitrary-precision-integers-included-.langur
@@ -2,8 +2,8 @@ val xs = string(5 ^ 4 ^ 3 ^ 2)
writeln len(xs), " digits"
-if len(xs) > 39 and s2s(xs, 1..20) == "62060698786608744707" and
- s2s(xs, -20 .. -1) == "92256259918212890625" {
+if len(xs) > 39 and s2s(xs, of=1..20) == "62060698786608744707" and
+ s2s(xs, of=-20 .. -1) == "92256259918212890625" {
writeln "SUCCESS"
}
diff --git a/Task/Arbitrary-precision-integers-included-/M2000-Interpreter/arbitrary-precision-integers-included-.m2000 b/Task/Arbitrary-precision-integers-included-/M2000-Interpreter/arbitrary-precision-integers-included-.m2000
new file mode 100644
index 0000000000..5869a47e0f
--- /dev/null
+++ b/Task/Arbitrary-precision-integers-included-/M2000-Interpreter/arbitrary-precision-integers-included-.m2000
@@ -0,0 +1,17 @@
+module checkit {
+ z=4^(3^2)
+ z1=z/1024-1
+ m=Biginteger("5")
+ with m, "ToString" as m.ToString
+ p=Biginteger("1024")
+ method m, "intpower", p as m1
+ m=m1
+ for i=1 to z1
+ method m1, "multiply", m as m
+ ? len(m.tostring), i
+ refresh
+ next
+ a=m.tostring
+ Print left$(a, 20)+"..."+Right$(a,20)
+}
+checkit
diff --git a/Task/Archimedean-spiral/Ada/archimedean-spiral.ada b/Task/Archimedean-spiral/Ada/archimedean-spiral.ada
index 0cdfaae32f..e949fa2f1f 100644
--- a/Task/Archimedean-spiral/Ada/archimedean-spiral.ada
+++ b/Task/Archimedean-spiral/Ada/archimedean-spiral.ada
@@ -1,17 +1,18 @@
with Ada.Numerics.Elementary_Functions;
with SDL.Video.Windows.Makers;
+with SDL.Video.Rectangles;
with SDL.Video.Renderers.Makers;
with SDL.Events.Events;
procedure Archimedean_Spiral is
- Width : constant := 800;
- Height : constant := 800;
- A : constant := 4.2;
- B : constant := 3.2;
- T_First : constant := 4.0;
- T_Last : constant := 100.0;
+ Width : constant := 800;
+ Height : constant := 800;
+ A : constant := 4.2;
+ B : constant := 3.2;
+ T_First : constant := 4.0;
+ T_Last : constant := 100.0;
Window : SDL.Video.Windows.Window;
Renderer : SDL.Video.Renderers.Renderer;
@@ -29,8 +30,10 @@ procedure Archimedean_Spiral is
loop
R := A + B * T;
Renderer.Draw
- (Point => (X => Width / 2 + SDL.C.int (R * Cos (T, 2.0 * Pi)),
- Y => Height / 2 - SDL.C.int (R * Sin (T, 2.0 * Pi))));
+ (Point =>
+ SDL.Video.Rectangles.Point'
+ (X => Width / 2 + SDL.C.int (R * Cos (T, 2.0 * Pi)),
+ Y => Height / 2 - SDL.C.int (R * Sin (T, 2.0 * Pi))));
exit when T >= T_Last;
T := T + Step;
end loop;
@@ -53,14 +56,16 @@ begin
return;
end if;
- SDL.Video.Windows.Makers.Create (Win => Window,
- Title => "Archimedean spiral",
- Position => SDL.Natural_Coordinates'(X => 10, Y => 10),
- Size => SDL.Positive_Sizes'(Width, Height),
- Flags => 0);
+ SDL.Video.Windows.Makers.Create
+ (Win => Window,
+ Title => "Archimedean spiral",
+ Position => SDL.Natural_Coordinates'(X => 10, Y => 10),
+ Size => SDL.Positive_Sizes'(Width, Height),
+ Flags => 0);
SDL.Video.Renderers.Makers.Create (Renderer, Window.Get_Surface);
Renderer.Set_Draw_Colour ((0, 0, 0, 255));
- Renderer.Fill (Rectangle => (0, 0, Width, Height));
+ Renderer.Fill
+ (Rectangle => SDL.Video.Rectangles.Rectangle'(0, 0, Width, Height));
Renderer.Set_Draw_Colour ((0, 220, 0, 255));
Draw_Archimedean_Spiral;
diff --git a/Task/Archimedean-spiral/Aquarius-BASIC/archimedean-spiral.basic b/Task/Archimedean-spiral/Aquarius-BASIC/archimedean-spiral.basic
new file mode 100644
index 0000000000..fc325caa2a
--- /dev/null
+++ b/Task/Archimedean-spiral/Aquarius-BASIC/archimedean-spiral.basic
@@ -0,0 +1,8 @@
+10 PRINT CHR$(11);
+20 PI=3.141593
+30 FOR I=0 TO 1080
+40 R=I/42+2
+50 X=R*SIN(I*PI/180)
+60 Y=R*COS(I*PI/180)*1.4
+70 PSET(39+X,33+Y)
+80 NEXT
diff --git a/Task/Archimedean-spiral/Atari-BASIC/archimedean-spiral.basic b/Task/Archimedean-spiral/Atari-BASIC/archimedean-spiral.basic
new file mode 100644
index 0000000000..ff20bc9dcf
--- /dev/null
+++ b/Task/Archimedean-spiral/Atari-BASIC/archimedean-spiral.basic
@@ -0,0 +1,9 @@
+10 GRAPHICS 8:COLOR 0:DEG
+20 N=5.4
+30 FOR I=0 TO N*360 STEP 10
+40 R=I/24+4
+50 X=R*SIN(I)
+60 Y=R*COS(I)
+70 DRAWTO 160+X,80+Y
+80 COLOR 1
+90 NEXT I
diff --git a/Task/Archimedean-spiral/Crystal/archimedean-spiral.cr b/Task/Archimedean-spiral/Crystal/archimedean-spiral.cr
new file mode 100644
index 0000000000..8644de1114
--- /dev/null
+++ b/Task/Archimedean-spiral/Crystal/archimedean-spiral.cr
@@ -0,0 +1,42 @@
+# output utilities -- solution starts after them
+def print_line (line)
+ (0..line[0].size-1).step(2) do |i|
+ char = ((line[0][i] | line[1][i] << 1 | line[2][i] << 2 |
+ line[0][i+1] << 3 | line[1][i+1] << 4 | line[2][i+1] << 5 |
+ line[3][i] << 6 | line[3][i+1] << 7) + 0x2800).chr
+ print char
+ end
+ puts
+end
+
+def print_dots (coords, screen_width)
+ coords = coords.sort_by {|x, y| y}
+ left, right = coords.map(&.first).minmax
+ if screen_width.odd?
+ screen_width -= 1
+ end
+ factor = screen_width / (right - left + 1)
+ line = (0..3).map { Array(UInt32).new(screen_width, 0) }
+ row = (coords[0].last * factor).to_i
+ coords.map {|x, y| {((x - left) * factor).to_i, (y * factor).to_i} }.each do |x, y|
+ while y > row+3
+ print_line line
+ line.each do |stripe| stripe.fill(0) end
+ row += 4
+ end
+ line[y - row][x] = 1
+ end
+ print_line line
+end
+
+# actual solution starts here:
+
+def spiral (a, b, step_resolution, step_count)
+ start, stop = 0.0, step_count * step_resolution
+ (start..stop).step(step_resolution).map { |theta|
+ r = a + b * theta
+ { r * Math.cos(theta), r * Math.sin(theta) }
+ }.to_a
+end
+
+print_dots(spiral(10, 10, 0.01, 4000), 60)
diff --git a/Task/Archimedean-spiral/M2000-Interpreter/archimedean-spiral.m2000 b/Task/Archimedean-spiral/M2000-Interpreter/archimedean-spiral.m2000
index 5f9e9e7555..49b7017044 100644
--- a/Task/Archimedean-spiral/M2000-Interpreter/archimedean-spiral.m2000
+++ b/Task/Archimedean-spiral/M2000-Interpreter/archimedean-spiral.m2000
@@ -5,7 +5,7 @@ module Archimedean_spiral {
pen #FFFF00
refresh 5000
every 1000 {
- \\ redifine window (console width and height) and place it to center (symbol ;)
+ \\ redefine window (console width and height) and place it to center (symbol ;)
Window 12, random(10, 18)*1000, random(8, 12)*1000;
move scale.x/2, scale.y/2
let N=2, k1=pi/120, k=k1, op=5, op1=1
diff --git a/Task/Archimedean-spiral/Nim/archimedean-spiral.nim b/Task/Archimedean-spiral/Nim/archimedean-spiral.nim
index 004dbe69f8..fec5dd2a2b 100644
--- a/Task/Archimedean-spiral/Nim/archimedean-spiral.nim
+++ b/Task/Archimedean-spiral/Nim/archimedean-spiral.nim
@@ -1,38 +1,38 @@
-import math
-
-import gintro/[glib, gobject, gtk, gio, cairo]
+import std/math
+import cairo
const
- Width = 601
- Height = 601
+ Width = 400
+ Height = 400
Limit = 12 * math.PI
Origin = (x: float(Width div 2), y: float(Height div 2))
B = floor((Width div 2) / Limit)
-#---------------------------------------------------------------------------------------------------
-proc draw(area: DrawingArea; context: Context) =
+proc drawSpiral(surface: ptr Surface) =
## Draw the spiral.
+ let context = create(surface)
+
var theta = 0.0
var delta = 0.01
var (prevx, prevy) = Origin
# Clear the region.
context.moveTo(0, 0)
- context.setSource(0.0, 0.0, 0.0)
+ context.setSourceRgb(0.0, 0.0, 0.0)
context.paint()
# Draw the spiral.
- context.setSource(1.0, 1.0, 0.0)
+ context.setSourceRgb(1.0, 1.0, 0.0)
context.moveTo(Origin.x, Origin.y)
while theta < Limit:
let r = B * theta
- let x = Origin.x + r * cos(theta) # X-coordinate on drawing area.
- let y = Origin.y + r * sin(theta) # Y-coordinate on drawing area.
+ let x = Origin.x + r * cos(theta)
+ let y = Origin.y + r * sin(theta)
context.lineTo(x, y)
context.stroke()
# Set data for next round.
@@ -41,34 +41,11 @@ proc draw(area: DrawingArea; context: Context) =
prevy = y
theta += delta
-#---------------------------------------------------------------------------------------------------
+ context.destroy()
-proc onDraw(area: DrawingArea; context: Context; data: pointer): bool =
- ## Callback to draw/redraw the drawing area contents.
- area.draw(context)
- result = true
-
-#---------------------------------------------------------------------------------------------------
-
-proc activate(app: Application) =
- ## Activate the application.
-
- let window = app.newApplicationWindow()
- window.setSizeRequest(Width, Height)
- window.setTitle("Archimedean spiral")
-
- # Create the drawing area.
- let area = newDrawingArea()
- window.add(area)
-
- # Connect the "draw" event to the callback to draw the spiral.
- discard area.connect("draw", ondraw, pointer(nil))
-
- window.showAll()
-
-#———————————————————————————————————————————————————————————————————————————————————————————————————
-
-let app = newApplication(Application, "Rosetta.spiral")
-discard app.connect("activate", activate)
-discard app.run()
+let surface = imageSurfaceCreate(FormatRgb24, Width, Height)
+surface.drawSpiral()
+if surface.writeToPng("archimedean_spiral.png") != StatusSuccess:
+ quit "Error while saving file.", QuitFailure
+surface.destroy()
diff --git a/Task/Arithmetic-Complex/Langur/arithmetic-complex.langur b/Task/Arithmetic-Complex/Langur/arithmetic-complex.langur
new file mode 100644
index 0000000000..07c6898485
--- /dev/null
+++ b/Task/Arithmetic-Complex/Langur/arithmetic-complex.langur
@@ -0,0 +1,22 @@
+val conjugate = fn(c) {
+ if c is not complex: throw "expected complex number"
+ return complex(c[1], -c[2])
+}
+
+val examples = {
+ "-(1+1i)": -(1+1i),
+ "abs(1+1i)": abs(1+1i),
+ "(2+2i) + (5+13.2i)": (2+2i) + (5+13.2i),
+ "5 + (2+2i)": 5 + (2+2i),
+ "5i + (2+2i)": 5i + (2+2i),
+ "5i - (2+2i)": 5i - (2+2i),
+ "(1+1i) * (3.141592653589793+1.2i)": (1+1i) * (3.141592653589793+1.2i),
+ "(5+3i) / (4-3i)": (5+3i) / (4-3i),
+ "1 / (4-3i)": 1 / (4-3i),
+ "(4-3i) ^ 3": (4-3i) ^ 3,
+ "conjugate(7+21.0i)": conjugate(7+21.0i),
+}
+
+for e of examples {
+ writeln "{{e : 20}}: ", examples[e]
+}
diff --git a/Task/Arithmetic-Complex/M2000-Interpreter/arithmetic-complex.m2000 b/Task/Arithmetic-Complex/M2000-Interpreter/arithmetic-complex.m2000
new file mode 100644
index 0000000000..4d894f3c26
--- /dev/null
+++ b/Task/Arithmetic-Complex/M2000-Interpreter/arithmetic-complex.m2000
@@ -0,0 +1,152 @@
+Class Complex {
+private:
+ double vr, vi
+public:
+ property real {
+ value {link parent vr to vr : value=vr}
+ }
+ property imaginary {
+ value {link parent vi to vi : value=vi}
+ }
+ property toString {
+ value {
+ clear
+ ' so default variable VALUE deleted and again defined it as string
+ link parent vr, vi to vr, vi
+ if vi then
+ if vr then
+ if vi>0 then
+ if vi==1 then
+ value="("+vr+"+i)"
+ else
+ value="("+vr+"+"+vi+"i)"
+ end if
+ else
+ if vi==-1 then
+ value="("+vr+"-i)"
+ else
+ value="("+vr+""+vi+"i)"
+ end if
+ end if
+ else
+ if vi=1 then
+ value="(i)"
+ else.if vi=-1 then
+ value="(-i)"
+ else
+ value="("+vi+"i)"
+ end if
+ end if
+ else
+ value="("+vr+")"
+ end if
+ }
+ }
+ function final Arg {
+ declare m math
+ Method m, "Atan2", .vi, .vr as ret
+ =ret
+ }
+ function final exp(rr=10) {
+ double exp = 2.71828182845905^.vr
+ c=this
+ th=.vi/1.74532925199433E-02
+ c.vr<=round(exp * cos(th), rr)
+ c.vi<=round(exp * sin(th),rr)
+ =c
+ }
+ function final cabs {
+ if abs(.vr)=infinity or abs(.vi)=infinity then
+ =1.7976931348623157E+308 : break
+ end if
+ double c=abs(.vr), d=abs(.vi)
+ if c>d then
+ r=d/c : =c*sqrt(1+r*r)
+ else.if d==0 then
+ =c
+ else
+ r=c/d : =d*sqrt(1+r*r)
+ end if
+ }
+ function final clog {
+ c=this
+ c.vr<=ln(.cabs())
+ c.vi<=.Arg()
+ =c
+ }
+ function final pow {
+ if match("G") then
+ read p as Complex
+ else
+ read p1 as double
+ p=this:p.vr=p1:p.vi=0
+ end if
+ Read ? rr=10
+ exp=.clog()*p
+ c=exp.exp(rr)
+ c.vr=round(c.vr, rr)
+ c.vi=round(c.vi, rr)
+ =c
+ }
+ function final inv {
+ if .vr==0 and .vi==0 then error "zero complex num"
+ acb=this.conj()
+ c=this*acb
+ c.vi <= acb.vi/c.vr
+ c.vr <= acb.vr/c.vr
+ =c
+ }
+ function final conj {
+ c=this : c.vi-! : =c
+ }
+ function final absc {
+ c=this*.conj() : =sqrt(c.vr)
+ }
+ operator final "+" {
+ read k as Complex : .vr+= k.vr : .vi+= k.vi
+ }
+ operator final "-" {
+ read k as Complex : .vr-= k.vr : .vi-= k.vi
+ }
+ operator final high "*" {
+ read k as Complex
+ double ivr = .vr*k.vr-.vi*k.vi
+ .vi <= .vi*k.vr+.vr*k.vi
+ .vr <= ivr
+ }
+ operator final high "/" {
+ read k as Complex
+ k1=k*k.conj()
+ acb = this*k.conj()
+ .vr <= acb.vr/k1.vr
+ .vi <= acb.vi/k1.vr
+ }
+ operator final unary {
+ .vr-!
+ .vi-!
+ }
+
+class:
+ module Complex (.vr, .vi) {}
+}
+Module Check (filename as string="") {
+ def f(x)=x.toString
+ a=Complex(8,-3)
+ b=a.inv()
+ open filename for wide output as #f
+ Print #f, "A="+a.toString
+ Print #f, " r=";a.cabs();" θ=";a.Arg();" rad"
+ Print #f, "B="+b.toString+" as 1/A"
+ Print #f, " r=";b.cabs();" θ=";b.Arg();" rad"
+ Print #f, a.toString+"*"+b.toString+"="+f(a*b)
+ Print #f, Complex(1).toString+"/"+b.toString+"="+f(Complex(1)/b)
+ Print #f, a.toString+"/"+a.toString+"="+f(a/a)
+ Print #f, a.toString+"+"+a.toString+"="+f(a+a)
+ Print #f, a.toString+"-"+a.toString+"="+f(a-a)
+ Print #f, "-"+a.toString+"="+f(-a)
+ Print #f, "e^(πi)+1="+f(Complex(2.71828182845905).pow(Complex(0,pi))+Complex(1))
+ close #f
+ if filename<>"" then if exist(filename) then win "notepad", dir$+filename
+}
+Check "out.txt"
+Check ' just show here
diff --git a/Task/Arithmetic-Complex/REXX/arithmetic-complex.rexx b/Task/Arithmetic-Complex/REXX/arithmetic-complex.rexx
index e58b2f326c..fd21689cfc 100644
--- a/Task/Arithmetic-Complex/REXX/arithmetic-complex.rexx
+++ b/Task/Arithmetic-Complex/REXX/arithmetic-complex.rexx
@@ -1,23 +1,38 @@
-/*REXX program demonstrates how to support some math functions for complex numbers. */
-x = '(5,3i)' /*define X ─── can use I i J or j */
-y = "( .5, 6j)" /*define Y " " " " " " " */
+include Settings
-say ' addition: ' x " + " y ' = ' Cadd(x, y)
-say ' subtraction: ' x " - " y ' = ' Csub(x, y)
-say 'multiplication: ' x " * " y ' = ' Cmul(x, y)
-say ' division: ' x " ÷ " y ' = ' Cdiv(x, y)
-say ' inverse: ' x " = " Cinv(x, y)
-say ' conjugate of: ' x " = " Conj(x, y)
-say ' negation of: ' x " = " Cneg(x, y)
-exit /*stick a fork in it, we're all done. */
-/*──────────────────────────────────────────────────────────────────────────────────────*/
-Conj: procedure; parse arg a ',' b,c ',' d; call C#; return C$( a , -b )
-Cadd: procedure; parse arg a ',' b,c ',' d; call C#; return C$( a+c , b+d )
-Csub: procedure; parse arg a ',' b,c ',' d; call C#; return C$( a-c , b-d )
-Cmul: procedure; parse arg a ',' b,c ',' d; call C#; return C$( ac-bd , bc+ad)
-Cdiv: procedure; parse arg a ',' b,c ',' d; call C#; return C$((ac+bd)/s, (bc-ad)/s)
-Cinv: return Cdiv(1, arg(1))
-Cneg: return Cmul(arg(1), -1)
-C_: return word(translate(arg(1), , '{[(JjIi)]}') 0, 1) /*get # or 0*/
-C#: a=C_(a); b=C_(b); c=C_(c); d=C_(d); ac=a*c; ad=a*d; bc=b*c; bd=b*d;s=c*c+d*d; return
-C$: parse arg r,c; _='['r; if c\=0 then _=_","c'j'; return _"]" /*uses j */
+say version; say 'Arithmetic numbers'; say
+numeric digits 9
+divi. = 0; a = 0; c = 0
+do i = 1
+/* Is the number arithmetic? */
+ if Arithmetic(i) then do
+ a = a+1
+/* Is the number composite? */
+ if divi.0 > 2 then
+ c = c+1
+/* Output control */
+ if a <= 100 then do
+ if a = 1 then
+ say 'First 100 arithmetic numbers are'
+ call Charout ,Right(i,4)
+ if a//10 = 0 then
+ say
+ if a = 100 then
+ say
+ end
+ if a = 100 | a = 1000 | a = 10000 | a = 100000 | a = 1000000 then do
+ say 'The' a'th arithmetic number is' i
+ say 'Of the first' a 'numbers' c 'are composite'
+ say
+ end
+/* Max 1m, higher takes too long */
+ if a = 1000000 then
+ leave
+ end
+end
+say Format(Time('e'),,3) 'seconds'
+exit
+
+include Numbers
+include Functions
+include Abend
diff --git a/Task/Arithmetic-Complex/Uiua/arithmetic-complex.uiua b/Task/Arithmetic-Complex/Uiua/arithmetic-complex.uiua
new file mode 100644
index 0000000000..411190a2d5
--- /dev/null
+++ b/Task/Arithmetic-Complex/Uiua/arithmetic-complex.uiua
@@ -0,0 +1,11 @@
+Za ← ℂ 3 1.5 # 1.5+3i
+Zb ← ℂ 1.5 1.5 # 1.5+1.5i
++ Zb Za
+- Zb Za
+× Zb Za
+÷ Zb Za
+¯Za
+ℂ¯ °ℂ Za
+⌵ Za
+ⁿ Zb Za
+°ℂZa
diff --git a/Task/Arithmetic-Integer/Zig/arithmetic-integer.zig b/Task/Arithmetic-Integer/Zig/arithmetic-integer.zig
new file mode 100644
index 0000000000..564d8cc2b4
--- /dev/null
+++ b/Task/Arithmetic-Integer/Zig/arithmetic-integer.zig
@@ -0,0 +1,23 @@
+const std = @import("std");
+
+pub fn main() !void {
+ var buf: [1024]u8 = undefined;
+ const reader = std.io.getStdIn().reader();
+ const stdout = std.io.getStdOut().writer();
+ try stdout.writeAll("Enter two integers separated by a space: ");
+ const input = try reader.readUntilDelimiter(&buf, '\n');
+ const text = std.mem.trimRight(u8, input, "\r\n");
+
+ var it = std.mem.tokenizeScalar(u8, text, ' ');
+
+ const a = try std.fmt.parseInt(i64, it.next().?, 10);
+ const b = try std.fmt.parseInt(i64, it.next().?, 10);
+
+ try stdout.print("Values: a {d} b {d}\n", .{a, b});
+ try stdout.print("Sum: a + b = {d}\n", .{a + b});
+ try stdout.print("Difference: a - b = {d}\n", .{a - b});
+ try stdout.print("Product: a * b = {d}\n", .{a * b});
+ try stdout.print("Integer quotient: a / b = {d}\n", .{@divTrunc(a, b)}); //truncates towards 0
+ try stdout.print("Remainder: a % b = {d}\n", .{@rem(a, b)}); // same sign as first operand
+ try stdout.print("Exponentiation: math.pow = {d}\n", .{std.math.pow(i64, a, b)}); //no exponentiation operator
+}
diff --git a/Task/Arithmetic-Rational/REXX/arithmetic-rational.rexx b/Task/Arithmetic-Rational/REXX/arithmetic-rational.rexx
index 4d17ceb166..16e57b5dcc 100644
--- a/Task/Arithmetic-Rational/REXX/arithmetic-rational.rexx
+++ b/Task/Arithmetic-Rational/REXX/arithmetic-rational.rexx
@@ -1,87 +1,62 @@
-/*REXX program implements a reasonably complete rational arithmetic (using fractions).*/
-L=length(2**19 - 1) /*saves time by checking even numbers. */
- do j=2 by 2 to 2**19 - 1; s=0 /*ignore unity (which can't be perfect)*/
- mostDivs=eDivs(j); @= /*obtain divisors>1; zero sum; null @. */
- do k=1 for words(mostDivs) /*unity isn't return from eDivs here.*/
- r='1/'word(mostDivs, k); @=@ r; s=$fun(r, , s)
- end /*k*/
- if s\==1 then iterate /*Is sum not equal to unity? Skip it.*/
- say 'perfect number:' right(j, L) " fractions:" @
- end /*j*/
-exit /*stick a fork in it, we're all done. */
-/*──────────────────────────────────────────────────────────────────────────────────────*/
-$div: procedure; parse arg x; x=space(x,0); f= 'fractional division'
- parse var x n '/' d; d=p(d 1)
- if d=0 then call err 'division by zero:' x
- if \datatype(n,'N') then call err 'a non─numeric numerator:' x
- if \datatype(d,'N') then call err 'a non─numeric denominator:' x
- return n/d
-/*──────────────────────────────────────────────────────────────────────────────────────*/
-$fun: procedure; parse arg z.1,,z.2 1 zz.2; arg ,op; op=p(op '+')
-F= 'fractionalFunction'; do j=1 for 2; z.j=translate(z.j, '/', "_"); end /*j*/
-if abbrev('ADD' , op) then op= "+"
-if abbrev('DIVIDE' , op) then op= "/"
-if abbrev('INTDIVIDE', op, 4) then op= "÷"
-if abbrev('MODULUS' , op, 3) | abbrev('MODULO', op, 3) then op= "//"
-if abbrev('MULTIPLY' , op) then op= "*"
-if abbrev('POWER' , op) then op= "^"
-if abbrev('SUBTRACT' , op) then op= "-"
-if z.1=='' then z.1= (op\=="+" & op\=='-')
-if z.2=='' then z.2= (op\=="+" & op\=='-')
-z_=z.2
- /* [↑] verification of both fractions.*/
- do j=1 for 2
- if pos('/', z.j)==0 then z.j=z.j"/1"; parse var z.j n.j '/' d.j
- if \datatype(n.j,'N') then call err 'a non─numeric numerator:' n.j
- if \datatype(d.j,'N') then call err 'a non─numeric denominator:' d.j
- if d.j=0 then call err 'a denominator of zero:' d.j
- n.j=n.j/1; d.j=d.j/1
- do while \datatype(n.j,'W'); n.j=(n.j*10)/1; d.j=(d.j*10)/1
- end /*while*/ /* [↑] {xxx/1} normalizes a number. */
- g=gcd(n.j, d.j); if g=0 then iterate; n.j=n.j/g; d.j=d.j/g
- end /*j*/
+include Settings
- select
- when op=='+' | op=='-' then do; l=lcm(d.1,d.2); do j=1 for 2; n.j=l*n.j/d.j; d.j=l
- end /*j*/
- if op=='-' then n.2= -n.2; t=n.1 + n.2; u=l
- end
- when op=='**' | op=='↑' |,
- op=='^' then do; if \datatype(z_,'W') then call err 'a non─integer power:' z_
- t=1; u=1; do j=1 for abs(z_); t=t*n.1; u=u*d.1
- end /*j*/
- if z_<0 then parse value t u with u t /*swap U and T */
- end
- when op=='/' then do; if n.2=0 then call err 'a zero divisor:' zz.2
- t=n.1*d.2; u=n.2*d.1
- end
- when op=='÷' then do; if n.2=0 then call err 'a zero divisor:' zz.2
- t=trunc($div(n.1 '/' d.1)); u=1
- end /* [↑] this is integer division. */
- when op=='//' then do; if n.2=0 then call err 'a zero divisor:' zz.2
- _=trunc($div(n.1 '/' d.1)); t=_ - trunc(_) * d.1; u=1
- end /* [↑] modulus division. */
- when op=='ABS' then do; t=abs(n.1); u=abs(d.1); end
- when op=='*' then do; t=n.1 * n.2; u=d.1 * d.2; end
- when op=='EQ' | op=='=' then return $div(n.1 '/' d.1) = fDiv(n.2 '/' d.2)
- when op=='NE' | op=='\=' | op=='╪' | ,
- op=='¬=' then return $div(n.1 '/' d.1) \= fDiv(n.2 '/' d.2)
- when op=='GT' | op=='>' then return $div(n.1 '/' d.1) > fDiv(n.2 '/' d.2)
- when op=='LT' | op=='<' then return $div(n.1 '/' d.1) < fDiv(n.2 '/' d.2)
- when op=='GE' | op=='≥' | op=='>=' then return $div(n.1 '/' d.1) >= fDiv(n.2 '/' d.2)
- when op=='LE' | op=='≤' | op=='<=' then return $div(n.1 '/' d.1) <= fDiv(n.2 '/' d.2)
- otherwise call err 'an illegal function:' op
- end /*select*/
+say version; say 'Rational arithmetic'; say
+a = '1 2'; b = '-3 4'; c = '5 -6'; d = '-7 -8'; e = 3; f = 1.666666666
+say 'VALUES'
+say 'a =' Rlst2form(a)
+say 'b =' Rlst2form(b)
+say 'c =' Rlst2form(c)
+say 'd =' Rlst2form(d)
+say 'e =' e
+say 'f =' f
+say
+say 'BASICS'
+say 'a+b =' Rlst2form(Radd(a,b))
+say 'a+b+c+d =' Rlst2form(Radd(a,b,c,d))
+say 'a-b =' Rlst2form(Rsub(a,b))
+say 'a-b-c-d =' Rlst2form(Rsub(a,b,c,d))
+say 'a*b =' Rlst2form(Rmul(a,b))
+say 'a*b*c*d =' Rlst2form(Rmul(a,b,c,d))
+say 'a/b =' Rlst2form(Rdiv(a,b))
+say 'a/b/c/d =' Rlst2form(Rdiv(a,b,c,d))
+say '-a =' Rlst2form(Rneg(a))
+say '1/a =' Rlst2form(Rinv(a))
+say
+say 'COMPARE'
+say 'a=b =' Rge(a,b)
+say 'a>b =' Rgt(a,b)
+say 'a<>b =' Rne(a,b)
+say
+say 'BONUS'
+say 'Abs(c) =' Rlst2form(Rabs(c))
+say 'Float(b) =' Rfloat(b)
+say 'Neg(d) =' Rlst2form(Rneg(d))
+say 'Power(a,e) =' Rlst2form(Rpow(a,e))
+say 'Rational(f) =' Rlst2form(Rrat(f))
+say
+say 'FORMULA'
+say 'a^2-2ab+3c-4ad^4+5 = ',
+Rlst2form(Radd(Rpow(a,2),Rmul(-2,a,b),Rmul(3,c),Rmul(-4,a,Rpow(d,4)),5))
+say
+say 'PERFECT NUMBERS'
+call time('r')
+numeric digits 20
+do c = 6 to 2**19
+ s = 1 c; m = Isqrt(c)
+ do f = 2 to m
+ if c//f = 0 then do
+ s = Radd(s,1 f,1 c/f)
+ end
+ end
+ if Req(s,1) then
+ say c 'is a perfect number'
+end
+say time('e')/1's'
+exit
-if t==0 then return 0; g=gcd(t, u); t=t/g; u=u/g
-if u==1 then return t
- return t'/'u
-/*──────────────────────────────────────────────────────────────────────────────────────*/
-eDivs: procedure; parse arg x 1 b,a
- do j=2 while j*j>6
+ PUT col+1 IN col
+ IF col mod 10 = 0: WRITE/
+
+FOR m IN {1..20}:
+ WRITE "D(10^`m>>2`) = `(lagarias (10**m))/7`"/
diff --git a/Task/Arithmetic-derivative/ALGOL-68/arithmetic-derivative.alg b/Task/Arithmetic-derivative/ALGOL-68/arithmetic-derivative-1.alg
similarity index 100%
rename from Task/Arithmetic-derivative/ALGOL-68/arithmetic-derivative.alg
rename to Task/Arithmetic-derivative/ALGOL-68/arithmetic-derivative-1.alg
diff --git a/Task/Arithmetic-derivative/ALGOL-68/arithmetic-derivative-2.alg b/Task/Arithmetic-derivative/ALGOL-68/arithmetic-derivative-2.alg
new file mode 100644
index 0000000000..777a307ffd
--- /dev/null
+++ b/Task/Arithmetic-derivative/ALGOL-68/arithmetic-derivative-2.alg
@@ -0,0 +1,12 @@
+FOR n FROM -99 TO 100 DO
+ INT l := 0, f := 3, z := ABS n;
+ WHILE z >= 2 DO
+ WHILE z MOD 2 = 0 DO l +:= n OVER 2; z OVERAB 2 OD;
+ IF f <= z THEN
+ WHILE z MOD f = 0 DO l +:= n OVER f; z OVERAB f OD;
+ f +:= 2
+ FI
+ OD;
+ print( ( whole( l, -8 ) ) );
+ IF ( n + 100 ) MOD 10 = 0 THEN print( ( newline ) ) FI
+OD
diff --git a/Task/Arithmetic-derivative/APL/arithmetic-derivative.apl b/Task/Arithmetic-derivative/APL/arithmetic-derivative.apl
new file mode 100644
index 0000000000..1c399278d7
--- /dev/null
+++ b/Task/Arithmetic-derivative/APL/arithmetic-derivative.apl
@@ -0,0 +1,7 @@
+lagarias←{
+ ⍵<0:-∇-⍵
+ ⍵∊0 1:0
+ 0=d←⊃1+⍸0=(1↓⍳⌊⍵*÷2)|⍵:1
+ (n×∇d)+d×∇n←⍵÷d
+}
+lagarias¨ 20 10⍴¯100+⍳200
diff --git a/Task/Arithmetic-derivative/Action-/arithmetic-derivative.action b/Task/Arithmetic-derivative/Action-/arithmetic-derivative.action
new file mode 100644
index 0000000000..11a719733d
--- /dev/null
+++ b/Task/Arithmetic-derivative/Action-/arithmetic-derivative.action
@@ -0,0 +1,15 @@
+PROC Main()
+ INT n, f, l, z
+ FOR n = -99 TO 100 DO
+ l = 0 f = 3 IF n < 0 THEN z = - n ELSE z = n FI
+ WHILE z >= 2 DO
+ WHILE z MOD 2 = 0 DO l ==+ n / 2 z ==/ 2 OD
+ IF f <= z THEN
+ WHILE z MOD f = 0 DO l ==+ n / f z ==/ f OD
+ f ==+ 2
+ FI
+ OD
+ PrintF( "%8I", l )
+ IF ( n + 100 ) MOD 10 = 0 THEN PutE() FI
+ OD
+RETURN
diff --git a/Task/Arithmetic-derivative/Ada/arithmetic-derivative.ada b/Task/Arithmetic-derivative/Ada/arithmetic-derivative.ada
new file mode 100644
index 0000000000..9e3a37edda
--- /dev/null
+++ b/Task/Arithmetic-derivative/Ada/arithmetic-derivative.ada
@@ -0,0 +1,55 @@
+with Ada.Text_IO; use Ada.Text_IO;
+with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
+with Ada.Numerics.Big_Numbers.Big_Integers; use Ada.Numerics.Big_Numbers.Big_Integers;
+
+procedure Arithmetic_Derivative is
+
+ function D (N : Big_Integer) return Big_Integer is
+ Inc : Constant array (1 .. 8) of Big_Integer := (4, 2, 4, 2, 4, 6, 2, 6);
+ I : Integer := 1;
+ Num : Big_Integer := N;
+ P : Big_Integer := 2;
+ PCount : Big_Integer;
+ Result : Big_Integer := 0;
+ begin
+ if N < 0 then return -D(-N); end if;
+ if N = 0 or N = 1 then return 0; end if;
+
+ while P <= N / 2 loop
+ if Num mod P = 0 then
+ PCount := 0;
+ while Num mod P = 0 loop
+ Num := Num / P;
+ PCount := PCount + 1;
+ end loop;
+ Result := Result + (PCount * N) / P;
+ end if;
+ if Num = 1 then exit; end if;
+ if P >= 7 then
+ P := P + Inc(I);
+ I := (I mod 8) + 1;
+ end if;
+ if P = 3 or P = 5 then P := P + 2; end if;
+ if P = 2 then P := P + 1; end if;
+ end loop;
+
+ if Num > 1 then return 1; end if;
+
+ return result;
+ end D;
+
+ P : Big_Integer;
+
+begin
+ for I in Integer range -99 .. 100 loop
+ P := To_Big_Integer(I);
+ Put(To_String(Arg => D(P), Width => 5));
+ if I mod 10 = 0 then New_Line; end if;
+ end loop;
+
+ for I in Integer range 1 .. 20 loop
+ P := 10 ** I;
+ Put("D(10^"); Put(Item => I, Width => 2); Put(") / 7 = ");
+ Put(Big_Integer'Image(D(P) / 7)); New_Line;
+ end loop;
+end Arithmetic_Derivative;
diff --git a/Task/Arithmetic-derivative/BASIC/arithmetic-derivative.basic b/Task/Arithmetic-derivative/BASIC/arithmetic-derivative.basic
new file mode 100644
index 0000000000..1c7a401d8e
--- /dev/null
+++ b/Task/Arithmetic-derivative/BASIC/arithmetic-derivative.basic
@@ -0,0 +1,12 @@
+10 DEFINT A-Z
+20 FOR N=-99 TO 100
+30 GOSUB 100: PRINT USING "########";L;
+40 NEXT
+50 END
+100 L=0: F=3: Z=ABS(N)
+110 IF Z<2 THEN RETURN
+120 IF Z MOD 2=0 THEN L=L+N\2: Z=Z\2: GOTO 120
+130 IF F>Z THEN RETURN
+140 IF Z MOD F=0 THEN L=L+N\F: Z=Z\F: GOTO 140
+150 F=F+2
+160 GOTO 130
diff --git a/Task/Arithmetic-derivative/CLU/arithmetic-derivative.clu b/Task/Arithmetic-derivative/CLU/arithmetic-derivative.clu
new file mode 100644
index 0000000000..15fbee5766
--- /dev/null
+++ b/Task/Arithmetic-derivative/CLU/arithmetic-derivative.clu
@@ -0,0 +1,44 @@
+factors = iter (n: bigint) yields (bigint)
+ own zero: bigint := bigint$i2bi(0)
+ own two: bigint := bigint$i2bi(2)
+ own three: bigint := bigint$i2bi(3)
+
+ while n>zero cand n//two = zero do yield(two) n := n/two end
+
+ fac: bigint := three
+ while fac<=n do
+ while n//fac = zero do yield(fac) n := n/fac end
+ fac := fac + two
+ end
+end factors
+
+lagarias = proc (n: bigint) returns (bigint)
+ own zero: bigint := bigint$i2bi(0)
+ if n < zero then return(-lagarias(-n)) end
+
+ sum: bigint := zero
+ for fac: bigint in factors(n) do
+ sum := sum + n / fac
+ end
+ return(sum)
+end lagarias
+
+start_up = proc ()
+ own po: stream := stream$primary_output()
+ own seven: bigint := bigint$i2bi(7)
+ own ten: bigint := bigint$i2bi(10)
+
+ for n: int in int$from_to(-99, 100) do
+ stream$putright(po, bigint$unparse(lagarias(bigint$i2bi(n))), 7)
+ if (n + 100)//10 = 0 then stream$putl(po, "") end
+ end
+
+ for m: int in int$from_to(1, 20) do
+ d: bigint := lagarias(ten ** bigint$i2bi(m)) / seven
+ stream$puts(po, "D(10^")
+ stream$putright(po, int$unparse(m), 2)
+ stream$puts(po, ") / 7 = ")
+ stream$putright(po, bigint$unparse(d), 25)
+ stream$putl(po, "")
+ end
+end start_up
diff --git a/Task/Arithmetic-derivative/Cowgol/arithmetic-derivative.cowgol b/Task/Arithmetic-derivative/Cowgol/arithmetic-derivative.cowgol
new file mode 100644
index 0000000000..5a640ee1c3
--- /dev/null
+++ b/Task/Arithmetic-derivative/Cowgol/arithmetic-derivative.cowgol
@@ -0,0 +1,43 @@
+include "cowgol.coh";
+
+sub abs(n: int32): (r: uint32) is
+ if n<0 then
+ r := (-n) as uint32;
+ else
+ r := n as uint32;
+ end if;
+end sub;
+
+sub printcol(n: int32, s: uint8) is
+ var buf: uint8[12];
+ var ptr := IToA(n, 10, &buf[0]);
+ s := s - (ptr - &buf[0]) as uint8;
+ while s>0 loop
+ print_char(' ');
+ s := s-1;
+ end loop;
+ print(&buf[0]);
+end sub;
+
+sub lagarias(n: int32): (r: int32) is
+ var nn := abs(n);
+ r := 0;
+ if nn<2 then return; end if;
+ var f: uint32 := 2;
+ while f<=nn loop
+ while nn%f == 0 loop
+ r := r + n/f as int32;
+ nn := nn/f;
+ end loop;
+ f := f+1;
+ end loop;
+end sub;
+
+var i: int32 := -99;
+var c: uint8 := 0;
+while i <= 100 loop
+ printcol(lagarias(i), 7);
+ i := i+1;
+ c := c+1;
+ if c%10 == 0 then print_nl(); end if;
+end loop;
diff --git a/Task/Arithmetic-derivative/Draco/arithmetic-derivative.draco b/Task/Arithmetic-derivative/Draco/arithmetic-derivative.draco
new file mode 100644
index 0000000000..ae8d034c8c
--- /dev/null
+++ b/Task/Arithmetic-derivative/Draco/arithmetic-derivative.draco
@@ -0,0 +1,32 @@
+proc lagarias(int n) int:
+ int f, r, s;
+ if n<0 then
+ -lagarias(-n)
+ elif n<2 then
+ 0
+ else
+ s := 0;
+ r := n;
+ while r % 2 = 0 do
+ r := r / 2;
+ s := s + n / 2
+ od;
+ f := 3;
+ while f <= r do
+ while r % f = 0 do
+ r := r / f;
+ s := s + n / f
+ od;
+ f := f + 2
+ od;
+ s
+ fi
+corp
+
+proc main() void:
+ int n;
+ for n from -99 upto 100 do
+ write(lagarias(n):7);
+ if (n+100) % 10=0 then writeln() fi
+ od
+corp
diff --git a/Task/Arithmetic-derivative/FreeBASIC/arithmetic-derivative.basic b/Task/Arithmetic-derivative/FreeBASIC/arithmetic-derivative.basic
new file mode 100644
index 0000000000..5fa7e2e419
--- /dev/null
+++ b/Task/Arithmetic-derivative/FreeBASIC/arithmetic-derivative.basic
@@ -0,0 +1,46 @@
+Function aDerivative(Byval n As Longint) As Longint
+ If n < 0 Then Return -aDerivative(-n)
+ If n = 0 Or n = 1 Then Return 0
+ If n = 2 Then Return 1
+
+ Dim As Longint q, d = 2
+ Dim As Longint result = 1
+
+ While d * d <= n
+ If n Mod d = 0 Then
+ q = n \ d
+ result = q * aDerivative(d) + d * aDerivative(q)
+ Exit While
+ End If
+ d += 1
+ Wend
+
+ Return result
+End Function
+
+'Main program
+Print "Arithmetic derivatives for -99 through 100:"
+
+Dim As Integer col, n
+col = 0
+For n = -99 To 100
+ col += 1
+ Print Using "####"; aDerivative(n);
+ If col = 10 Then
+ Print
+ col = 0
+ Else
+ Print " ";
+ End If
+Next
+
+'Stretch task
+Print !"\n\nPowers of 10 derivatives divided by 7:"
+Dim As Double m = 1
+For n = 1 To 18 ' LongInt limit in FreeBASIC
+ m *= 10
+ Dim As Longint a = aDerivative(Clngint(m))
+ Print Using "D(10^&) / 7 = &"; n; a \ 7
+Next
+
+Sleep
diff --git a/Task/Arithmetic-derivative/FutureBasic/arithmetic-derivative.basic b/Task/Arithmetic-derivative/FutureBasic/arithmetic-derivative.basic
new file mode 100644
index 0000000000..b54e9393bb
--- /dev/null
+++ b/Task/Arithmetic-derivative/FutureBasic/arithmetic-derivative.basic
@@ -0,0 +1,30 @@
+// Arithmetic Derivative
+// https://rosettacode.org/wiki/Arithmetic_derivative#
+
+local fn DoIt( N as short) as short
+ short L,F,Z
+ L = 0: F = 3: Z = ABS(N)
+ IF Z<2 THEN exit fn
+
+ 1 IF Z MOD 2 = 0 THEN L=L+N\2: Z=Z\2: GOTO 1
+ 2 IF F>Z THEN exit fn
+ 3 IF Z MOD F = 0 THEN L=L+N\F: Z=Z\F: GOTO 2
+
+ F=F+2
+ goto 1
+
+end fn = L
+
+_Window = 1
+
+window _Window,@"Arithmetic Derivative",fn cgrectmake(0,0,640,400)
+windowcenter(_Window)
+
+short N,L,LineCount
+FOR N = -99 TO 100
+L = fn DoIt(N): PRINT USING "########";L;
+LineCount ++
+if LineCount = 10 then print : LineCount = 0
+NEXT
+
+handleevents
diff --git a/Task/Arithmetic-derivative/MAD/arithmetic-derivative.mad b/Task/Arithmetic-derivative/MAD/arithmetic-derivative.mad
new file mode 100644
index 0000000000..dd608891dc
--- /dev/null
+++ b/Task/Arithmetic-derivative/MAD/arithmetic-derivative.mad
@@ -0,0 +1,42 @@
+ NORMAL MODE IS INTEGER
+
+ INTERNAL FUNCTION(X,Y)
+ ENTRY TO REM.
+ FUNCTION RETURN X-(X/Y)*Y
+ END OF FUNCTION
+
+ INTERNAL FUNCTION(N)
+ ENTRY TO DERIV.
+ R = N
+ WHENEVER R.L.0, R = -R
+ WHENEVER R.L.2, FUNCTION RETURN 0
+ S = 0
+FAC2 WHENEVER REM.(R,2).E.0
+ S = S + N/2
+ R = R/2
+ TRANSFER TO FAC2
+ END OF CONDITIONAL
+ THROUGH FAC, FOR F=3, 2, F.G.R
+FACF WHENEVER REM.(R,F).E.0
+ S = S + N/F
+ R = R/F
+ TRANSFER TO FACF
+ END OF CONDITIONAL
+FAC CONTINUE
+ FUNCTION RETURN S
+ END OF FUNCTION
+
+ VECTOR VALUES LINEF = $10(I6)*$
+ DIMENSION LINE(10)
+ C = 0
+ THROUGH ITEM, FOR I=-99, 1, I.G.100
+ LINE(C) = DERIV.(I)
+ C = C+1
+ WHENEVER C.E.10
+ PRINT FORMAT LINEF,
+ 0 LINE(0),LINE(1),LINE(2),LINE(3),LINE(4),
+ 1 LINE(5),LINE(6),LINE(7),LINE(8),LINE(9)
+ C = 0
+ END OF CONDITIONAL
+ITEM CONTINUE
+ END OF PROGRAM
diff --git a/Task/Arithmetic-derivative/MiniScript/arithmetic-derivative.mini b/Task/Arithmetic-derivative/MiniScript/arithmetic-derivative.mini
index 1c297bd18d..91af00f19b 100644
--- a/Task/Arithmetic-derivative/MiniScript/arithmetic-derivative.mini
+++ b/Task/Arithmetic-derivative/MiniScript/arithmetic-derivative.mini
@@ -37,7 +37,7 @@ for n in range( -99, 100 )
end if
end for
print()
-for n in range( 1, 17 ) // 18, 19 and 20 would overflow ????? TODO: check
+for n in range( 1, 17 )
m = 10 ^ n
print( "D(" + str(m) + ") / 7 = " + str( floor (lagarias (m) / 7) ) )
end for
diff --git a/Task/Arithmetic-derivative/Miranda/arithmetic-derivative.miranda b/Task/Arithmetic-derivative/Miranda/arithmetic-derivative.miranda
new file mode 100644
index 0000000000..c4ecee4682
--- /dev/null
+++ b/Task/Arithmetic-derivative/Miranda/arithmetic-derivative.miranda
@@ -0,0 +1,24 @@
+main :: [sys_message]
+main = [Stdout (table 10 7 (map (show . lagarias) [-99..100])),
+ Stdout (lay (map ten_pow_m_div_7 [1..20]))]
+
+ten_pow_m_div_7 :: num->[char]
+ten_pow_m_div_7 m = "D(10^" ++ rjustify 2 (show m) ++ ") / 7 = " ++
+ show (lagarias (10^m) div 7)
+
+table :: num->num->[[char]]->[char]
+table w cw ls = lay [concat (map (rjustify cw) l) | l <- group w ls]
+
+group :: num->[*]->[[*]]
+group n [] = []
+group n ls = take n ls : group n (drop n ls)
+
+lagarias :: num->num
+lagarias n = -lagarias (-n), if n<0
+ = sum [n div f | f <- factors n], otherwise
+
+factors :: num->[num]
+factors n = f n 2
+ where f n d = [], if d > n
+ = d : f (n div d) d, if n mod d = 0
+ = f n (d+1), otherwise
diff --git a/Task/Arithmetic-derivative/PL-I/arithmetic-derivative.pli b/Task/Arithmetic-derivative/PL-I/arithmetic-derivative.pli
new file mode 100644
index 0000000000..179acc3c0a
--- /dev/null
+++ b/Task/Arithmetic-derivative/PL-I/arithmetic-derivative.pli
@@ -0,0 +1,27 @@
+arithmeticDerivative: procedure options(main);
+ lagarias: procedure(n) returns(fixed);
+ declare (n, res, fac, rem) fixed;
+ rem = abs(n);
+ if rem<2 then return(0);
+
+ res = 0;
+ do while(mod(rem,2) = 0);
+ res = res + n/2;
+ rem = rem/2;
+ end;
+
+ do fac=3 repeat(fac+2) while(fac<=rem);
+ do while(mod(rem,fac) = 0);
+ res = res + n/fac;
+ rem = rem/fac;
+ end;
+ end;
+ return(res);
+ end lagarias;
+
+ declare n fixed;
+ do n=-99 to 100;
+ put edit(lagarias(n)) (F(7));
+ if mod(n+100, 10)=0 then put skip;
+ end;
+end arithmeticDerivative;
diff --git a/Task/Arithmetic-derivative/PL-M/arithmetic-derivative.plm b/Task/Arithmetic-derivative/PL-M/arithmetic-derivative.plm
new file mode 100644
index 0000000000..d2e0a6eb98
--- /dev/null
+++ b/Task/Arithmetic-derivative/PL-M/arithmetic-derivative.plm
@@ -0,0 +1,66 @@
+100H: /* ARITHMETIC DERIVATIVE - BASED ON THE BASIC SAMPLE */
+
+ /* RETURNS TRUE IF A < B, FALSE OTHERWISE WITH A AND B TREATED AS SIGNED */
+ SIGNED$LT: PROCEDURE( A, B )BYTE;
+ DECLARE ( A, B ) ADDRESS;
+ IF ( A + 32768 ) < ( B + 32768 ) THEN RETURN 0FFH; ELSE RETURN 0;
+ END SIGNED$LT ;
+
+ /* RETURNS A / B WITH A AND B TREATED AS SIGNED */
+ SIGNED$DIV: PROCEDURE( AIN, BIN )ADDRESS;
+ DECLARE ( AIN, BIN )ADDRESS;
+ DECLARE ( A, B, SIGN )ADDRESS;
+ SIGN = 1;
+ A = AIN;
+ B = BIN;
+ IF SIGNED$LT( A, 0 ) THEN DO;
+ SIGN = - SIGN;
+ A = - A;
+ END;
+ IF SIGNED$LT( B, 0 ) THEN DO;
+ SIGN = - SIGN;
+ B = - B;
+ END;
+ RETURN ( A / B ) * SIGN;
+ END SIGNED$DIV ;
+
+ /* CP/M BDOS SYSTEM CALL AND I/O ROUTINES */
+ BDOS: PROCEDURE( FN, ARG ); DECLARE FN BYTE, ARG ADDRESS; GOTO 5; END;
+ PR$CHAR: PROCEDURE( C ); DECLARE C BYTE; CALL BDOS( 2, C ); END;
+ PR$STRING: PROCEDURE( S ); DECLARE S ADDRESS; CALL BDOS( 9, S ); END;
+ PR$NL: PROCEDURE; CALL PR$CHAR( 0DH ); CALL PR$CHAR( 0AH ); END;
+
+ PR$SIGNED$NUMBER: PROCEDURE( N ); /* PRINTS A SIGNED NUMBER */
+ DECLARE N ADDRESS;
+ DECLARE V ADDRESS, N$STR ( 9 )BYTE, W BYTE;
+ IF SIGNED$LT( N, 0 ) THEN V = - N; ELSE V = N;
+ DO W = 0 TO LAST( N$STR ); N$STR( W ) = ' '; END;
+ W = LAST( N$STR );
+ N$STR( W ) = '$';
+ N$STR( W := W - 1 ) = '0' + ( V MOD 10 );
+ DO WHILE( ( V := V / 10 ) > 0 );
+ N$STR( W := W - 1 ) = '0' + ( V MOD 10 );
+ END;
+ IF SIGNED$LT( N, 0 ) THEN N$STR( W := W - 1 ) = '-';
+ CALL PR$STRING( .N$STR );
+ END PR$SIGNED$NUMBER;
+
+ /* TASK */
+
+ DECLARE ( C, N, L, F, Z ) ADDRESS;
+
+ DO C = 1 TO 200;
+ N = C - 100;
+ L = 0; F = 3; IF SIGNED$LT( N, 0 ) THEN Z = - N; ELSE Z = N;
+ DO WHILE Z >= 2;
+ DO WHILE Z MOD 2 = 0; L = L + SIGNED$DIV( N, 2 ); Z = Z / 2; END;
+ IF F <= Z THEN DO;
+ DO WHILE Z MOD F = 0; L = L + SIGNED$DIV( N, F ); Z = Z / F; END;
+ F = F + 2;
+ END;
+ END;
+ CALL PR$SIGNED$NUMBER( L );
+ IF C MOD 10 = 0 THEN CALL PR$NL;
+ END;
+
+EOF
diff --git a/Task/Arithmetic-derivative/Refal/arithmetic-derivative.refal b/Task/Arithmetic-derivative/Refal/arithmetic-derivative.refal
new file mode 100644
index 0000000000..d124d001a8
--- /dev/null
+++ b/Task/Arithmetic-derivative/Refal/arithmetic-derivative.refal
@@ -0,0 +1,32 @@
+$ENTRY Go {
+ = >>
+};
+
+Lagarias {
+ '-' e.N = '-' ;
+ 0 = 0;
+ 1 = 0;
+ e.N, : {
+ e.N = 1;
+ e.F, : e.R =
+ >
+ >>;
+ };
+};
+
+Fac {
+ (e.F) e.N, : e.N2,
+ : '+' = e.N;
+ (e.F) e.N, : 0 = e.F;
+ (e.F) e.N = ) e.N>;
+ e.N = ;
+};
+
+Table { s.C s.W e.L = >>; };
+Line { s.W e.X = >; };
+Fmt { s.W e.X, >: (e.Z) e.C = e.C; };
+Rep { 0 s.C = ; s.N s.C = s.C s.C>; };
+Join { = ; (e.X) e.Y = e.X ; };
+Group { s.N = ; s.N e.X, : (e.G) e.R = (e.G) ; };
+Each { (e.F) = ; (e.F) (e.X) e.XS = () ; };
+Iota { (e.E) e.E = (e.E); (e.S) e.E = (e.S) ) e.E>; };
diff --git a/Task/Arithmetic-derivative/SETL/arithmetic-derivative.setl b/Task/Arithmetic-derivative/SETL/arithmetic-derivative.setl
new file mode 100644
index 0000000000..e48e921bf7
--- /dev/null
+++ b/Task/Arithmetic-derivative/SETL/arithmetic-derivative.setl
@@ -0,0 +1,25 @@
+program arithmetic_derivative;
+ loop for n in [-99..100] do
+ nprint(lpad(str lagarias(n), 6));
+ if (col +:= 1) mod 10 = 0 then
+ print;
+ end if;
+ end loop;
+
+ loop for m in [1..20] do
+ nprint("D(10^" + lpad(str m, 2) + ") / 7 = ");
+ print(lagarias(10**m) div 7);
+ end loop;
+
+ proc lagarias(n);
+ return if n<0 then
+ -lagarias(-n)
+ elseif n in {0,1} then
+ 0
+ elseif forall d in {2..floor sqrt n} | n mod d /= 0 then
+ 1
+ else
+ (n div d)*lagarias(d) + d*lagarias(n div d)
+ end;
+ end proc;
+end program;
diff --git a/Task/Arithmetic-derivative/Sidef/arithmetic-derivative-1.sidef b/Task/Arithmetic-derivative/Sidef/arithmetic-derivative-1.sidef
new file mode 100644
index 0000000000..171928e84f
--- /dev/null
+++ b/Task/Arithmetic-derivative/Sidef/arithmetic-derivative-1.sidef
@@ -0,0 +1,9 @@
+say "Arithmetic derivative for n in range [-99, 100]:"
+-99 .. 100 -> map { .arithmetic_derivative }.each_slice(10, {|*a|
+ a.map { '%4s' % _ }.join(' ').say
+})
+
+say "\nArithmetic derivative D(10^n)/7 for n in range [1, 20]:"
+for n in (1..20) {
+ say "D(10^#{n})/7 = #{arithmetic_derivative(10**n) / 7}"
+}
diff --git a/Task/Arithmetic-derivative/Sidef/arithmetic-derivative-2.sidef b/Task/Arithmetic-derivative/Sidef/arithmetic-derivative-2.sidef
new file mode 100644
index 0000000000..d9d62d3285
--- /dev/null
+++ b/Task/Arithmetic-derivative/Sidef/arithmetic-derivative-2.sidef
@@ -0,0 +1,26 @@
+subset Integer < Number { .is_int }
+subset Positive < Integer { .is_pos }
+subset Negative < Integer { .is_neg }
+subset Prime < Positive { .is_prime }
+
+func arithmetic_derivative((0)) { 0 }
+func arithmetic_derivative((1)) { 0 }
+
+func arithmetic_derivative(Prime _) { 1 }
+
+func arithmetic_derivative(Negative n) {
+ -arithmetic_derivative(-n)
+}
+
+func arithmetic_derivative(Positive n) is cached {
+
+ var a = n.factor.rand
+ var b = n/a
+
+ arithmetic_derivative(a)*b + a*arithmetic_derivative(b)
+}
+
+func arithmetic_derivative(Number n) {
+ var (a, b) = n.nude
+ (arithmetic_derivative(a)*b - arithmetic_derivative(b)*a) / b**2
+}
diff --git a/Task/Arithmetic-numbers/REXX/arithmetic-numbers-2.rexx b/Task/Arithmetic-numbers/REXX/arithmetic-numbers-2.rexx
deleted file mode 100644
index cb506d1077..0000000000
--- a/Task/Arithmetic-numbers/REXX/arithmetic-numbers-2.rexx
+++ /dev/null
@@ -1,76 +0,0 @@
-parse Version version
-say version; say 'Arithmetic numbers'; say
-Call time 'R'
-numeric digits 9
-a = 0; c = 0
-do i = 1
-/* Is the number arithmetic? */
- if Arithmetic(i) then do
- a = a+1
-/* Is the number composite? */
- if divi.0 > 2 then
- c = c+1
-/* Output control */
- if a <= 100 then do
- if a = 1 then
- say 'First 100 arithmetic numbers are'
- call Charout ,Right(i,4)
- if a//10 = 0 then
- say
- if a = 100 then
- say
- end
- if a = 100 | a = 1000 | a = 10000 | a = 100000 | a = 1000000 then do
- say 'The' a'th arithmetic number is' i
- say 'Of the first' a 'numbers' c 'are composite'
- say
- end
-/* Max 1m, higher takes too long */
- if a = 1000000 then
- leave
- end
-end
-say Format(Time('e'),,3) 'seconds'
-exit
-
-Arithmetic:
-/* Is a number arithmetic? function */
-procedure expose divi.
-arg x
-/* Cf definition */
-s = Sigma(x)
-if Whole(s/divi.0) then
- return 1
-else
- return 0
-
-Sigma:
-/* Sigma = Sum of all divisors of x including 1 and x */
-procedure expose divi.
-arg xx
-/* Fast values */
-if xx = 1 then do
- divi.0 = 1
- return 1
-end
-/* Euclid's method */
-m = xx//2; yy = 1+xx; n = 2
-do j = 2+m by 1+m while j*j < xx
- if xx//j = 0 then do
- yy = yy+j+xx%j; n = n+2
- end
-end
-if j*j = xx then do
- yy = yy+j; n = n+1
-end
-/* Store number of divisors */
-divi.0 = n
-/* Return sum */
-return yy
-
-Whole:
-/* Is a number integer? */
-procedure
-arg xx
-/* Formula */
-return Datatype(xx,'w')
diff --git a/Task/Arithmetic-numbers/REXX/arithmetic-numbers-1.rexx b/Task/Arithmetic-numbers/REXX/arithmetic-numbers.rexx
similarity index 82%
rename from Task/Arithmetic-numbers/REXX/arithmetic-numbers-1.rexx
rename to Task/Arithmetic-numbers/REXX/arithmetic-numbers.rexx
index 6094ba7514..fd21689cfc 100644
--- a/Task/Arithmetic-numbers/REXX/arithmetic-numbers-1.rexx
+++ b/Task/Arithmetic-numbers/REXX/arithmetic-numbers.rexx
@@ -2,7 +2,7 @@ include Settings
say version; say 'Arithmetic numbers'; say
numeric digits 9
-a = 0; c = 0
+divi. = 0; a = 0; c = 0
do i = 1
/* Is the number arithmetic? */
if Arithmetic(i) then do
@@ -33,17 +33,6 @@ end
say Format(Time('e'),,3) 'seconds'
exit
-Arithmetic:
-/* Is a number arithmetic? function */
-procedure expose divi.
-arg x
-/* Cf definition */
-s = Sigma(x)
-if Whole(s/divi.0) then
- return 1
-else
- return 0
-
include Numbers
include Functions
include Abend
diff --git a/Task/Arithmetic-numbers/Sidef/arithmetic-numbers.sidef b/Task/Arithmetic-numbers/Sidef/arithmetic-numbers.sidef
new file mode 100644
index 0000000000..0530ed1c31
--- /dev/null
+++ b/Task/Arithmetic-numbers/Sidef/arithmetic-numbers.sidef
@@ -0,0 +1,14 @@
+func is_arithmetic(n) {
+ n.tau `divides` n.sigma
+}
+
+say "The first one hundred arithmetic numbers:"
+100.by(is_arithmetic).each_slice(10, {|*a|
+ a.map { '%3s' % _ }.join(' ').say
+})
+
+for x in (1e3, 1e4, 1e5, 1e6) {
+ var arr = x.by(is_arithmetic)
+ say "\n#{x}th arithmetic number is #{arr.last}."
+ say "There are #{arr.count{.is_composite}} composite arithmetic numbers <= #{arr.last}."
+}
diff --git a/Task/Assertions/FutureBasic/assertions.basic b/Task/Assertions/FutureBasic/assertions.basic
new file mode 100644
index 0000000000..0572a113ad
--- /dev/null
+++ b/Task/Assertions/FutureBasic/assertions.basic
@@ -0,0 +1 @@
+cln NSAssert(a == 42, @"Error message");
diff --git a/Task/Assertions/Uiua/assertions.uiua b/Task/Assertions/Uiua/assertions.uiua
new file mode 100644
index 0000000000..582a84d525
--- /dev/null
+++ b/Task/Assertions/Uiua/assertions.uiua
@@ -0,0 +1,2 @@
+r ← 41
+⍤"r doesn't equal 42!" =42 r
diff --git a/Task/Associative-array-Creation/Uiua/associative-array-creation.uiua b/Task/Associative-array-Creation/Uiua/associative-array-creation.uiua
new file mode 100644
index 0000000000..eb353f2a2b
--- /dev/null
+++ b/Task/Associative-array-Creation/Uiua/associative-array-creation.uiua
@@ -0,0 +1 @@
+map [1 2] {"foo" "bar"}
diff --git a/Task/Associative-array-Iteration/Uiua/associative-array-iteration.uiua b/Task/Associative-array-Iteration/Uiua/associative-array-iteration.uiua
new file mode 100644
index 0000000000..e93ccc48ba
--- /dev/null
+++ b/Task/Associative-array-Iteration/Uiua/associative-array-iteration.uiua
@@ -0,0 +1,5 @@
+x ← .map [3 9 7] {"foo" "bar" "hey"} # Using the example from the 'Creation' page
+.⊟°map x # Decouple the hashmap and put a copy of it on the stack
+&p.⊢ # Get the keys as a new array and print them
+&p⊣: # Get the values as a new array and print them
+&p⧅◌ # Get keys mapped to values
diff --git a/Task/Associative-array-Merging/Uiua/associative-array-merging.uiua b/Task/Associative-array-Merging/Uiua/associative-array-merging.uiua
new file mode 100644
index 0000000000..a9f9bb2ba1
--- /dev/null
+++ b/Task/Associative-array-Merging/Uiua/associative-array-merging.uiua
@@ -0,0 +1,19 @@
+Base ← map {"name" "price" "color"} {"Rocket Skates" 12.75 "yellow"}
+Update ← map {"price" "color" "year"} {15.25 "red" 1974}
+&pBase
+&pUpdate
+UnmapAndPop ← ◌: °map
+GetAndMap ← ˜map˜get
+
+°⊂ UnmapAndPop Base UnmapAndPop Update
+Base.
+GetAndMap
+.:◌:
+Update
+GetAndMap
+&p"\n"
+&p⊂
+&p"\n"
+
+&pBase
+&pUpdate
diff --git a/Task/Average-loop-length/YAMLScript/average-loop-length.ys b/Task/Average-loop-length/YAMLScript/average-loop-length.ys
index afb2ab3f81..4b3bde0c68 100644
--- a/Task/Average-loop-length/YAMLScript/average-loop-length.ys
+++ b/Task/Average-loop-length/YAMLScript/average-loop-length.ys
@@ -1,4 +1,4 @@
-!yamlscript/v0
+!YS-v0
# Use *' (vs. *) to allow arbitrary length arithmetic:
mul =: value("*'")
diff --git a/Task/Averages-Arithmetic-mean/Langur/averages-arithmetic-mean.langur b/Task/Averages-Arithmetic-mean/Langur/averages-arithmetic-mean.langur
index f313eb66b4..ad6e0ac086 100644
--- a/Task/Averages-Arithmetic-mean/Langur/averages-arithmetic-mean.langur
+++ b/Task/Averages-Arithmetic-mean/Langur/averages-arithmetic-mean.langur
@@ -1,4 +1,4 @@
-val umean = fn x:fold(fn{+}, x) / len(x)
+val umean = fn x:fold(x, by=fn{+}) / len(x)
writeln " custom: ", umean([7, 3, 12])
writeln "built-in: ", mean([7, 3, 12])
diff --git a/Task/Averages-Arithmetic-mean/Ursalang/averages-arithmetic-mean.ursa b/Task/Averages-Arithmetic-mean/Ursalang/averages-arithmetic-mean.ursa
new file mode 100644
index 0000000000..f678c19151
--- /dev/null
+++ b/Task/Averages-Arithmetic-mean/Ursalang/averages-arithmetic-mean.ursa
@@ -0,0 +1,8 @@
+let mean = fn(l) {
+ var tot = 0
+ for i in l.iter() {
+ tot := tot + i
+ }
+ return tot/l.len()
+}
+print(mean([10, 30, 50, 5, 5]))
diff --git a/Task/Averages-Mean-angle/Julia/averages-mean-angle-2.jl b/Task/Averages-Mean-angle/Julia/averages-mean-angle-2.jl
index cefb410d21..9bd21ffb79 100644
--- a/Task/Averages-Mean-angle/Julia/averages-mean-angle-2.jl
+++ b/Task/Averages-Mean-angle/Julia/averages-mean-angle-2.jl
@@ -1,8 +1,8 @@
julia> meandegrees([350, 10])
0.0
-julia> meandegrees([90, 180, 270, 360]])
+julia> meandegrees([90, 180, 270, 360])
0.0
-julia> meandegrees([10, 20, 30]])
+julia> meandegrees([10, 20, 30])
19.999999999999996
diff --git a/Task/Averages-Mode/Ursalang/averages-mode.ursa b/Task/Averages-Mode/Ursalang/averages-mode.ursa
new file mode 100644
index 0000000000..4201bfb04e
--- /dev/null
+++ b/Task/Averages-Mode/Ursalang/averages-mode.ursa
@@ -0,0 +1,20 @@
+let mode = fn(l) {
+ let m = {}
+ for i in l.iter() {
+ let old = m.get(i)
+ let new = if old == null {1} else {old + 1}
+ m.set(i, new)
+ }
+ var max = 0
+ var mode = null
+ for i in m.iter() {
+ if i.get(1) > max {
+ max := i.get(1)
+ mode := i.get(0)
+ }
+ }
+ return mode
+}
+
+print(mode([4, 6, 66, 66, 9, 22, 9, 9, 23, 43, 2, 43]))
+print(mode(["abc", "def", "ghi", "abc"]))
diff --git a/Task/Averages-Root-mean-square/Raku/averages-root-mean-square-2.raku b/Task/Averages-Root-mean-square/Raku/averages-root-mean-square-2.raku
index e813d829a8..2bb7f6aecd 100644
--- a/Task/Averages-Root-mean-square/Raku/averages-root-mean-square-2.raku
+++ b/Task/Averages-Root-mean-square/Raku/averages-root-mean-square-2.raku
@@ -1 +1 @@
-sub rms { sqrt @_ R/ [+] @_ X** 2 }
+sub rms { sqrt @_ R/ [+] @_».² }
diff --git a/Task/Averages-Root-mean-square/Ursalang/averages-root-mean-square.ursa b/Task/Averages-Root-mean-square/Ursalang/averages-root-mean-square.ursa
new file mode 100644
index 0000000000..cd5c2e381a
--- /dev/null
+++ b/Task/Averages-Root-mean-square/Ursalang/averages-root-mean-square.ursa
@@ -0,0 +1,5 @@
+var tot = 0
+for i in range(10) {
+ tot := tot + (i + 1) ** 2
+}
+print(sqrt(tot/10))
diff --git a/Task/Averages-Simple-moving-average/M2000-Interpreter/averages-simple-moving-average-1.m2000 b/Task/Averages-Simple-moving-average/M2000-Interpreter/averages-simple-moving-average-1.m2000
new file mode 100644
index 0000000000..3e70598a48
--- /dev/null
+++ b/Task/Averages-Simple-moving-average/M2000-Interpreter/averages-simple-moving-average-1.m2000
@@ -0,0 +1,28 @@
+module Simple_moving_average {
+ smaMAKER=lambda (m) -> {
+ s=stack
+ =lambda m, s (N) -> {
+ stack s {
+ if len(s)=m then drop
+ data N
+ }
+ = array(stack(s))#sum()/len(s)
+ }
+ }
+ Print "Period = 3"
+ ma=smaMaker(3)
+ test(0, 9)
+ Print "Period = 5"
+ ma=smaMaker(5)
+ test(9, 0)
+ end
+ sub test(A, B)
+ local i
+ Print
+ for i=A to B
+ Print "Add ";i;" => moving average ";ma(i)
+ next
+ Print
+ end sub
+}
+Simple_moving_average
diff --git a/Task/Averages-Simple-moving-average/M2000-Interpreter/averages-simple-moving-average-2.m2000 b/Task/Averages-Simple-moving-average/M2000-Interpreter/averages-simple-moving-average-2.m2000
new file mode 100644
index 0000000000..6ebf41e00a
--- /dev/null
+++ b/Task/Averages-Simple-moving-average/M2000-Interpreter/averages-simple-moving-average-2.m2000
@@ -0,0 +1,37 @@
+module Simple_moving_average {
+ class smaMaker {
+ private:
+ s=stack
+ m
+ public:
+ set {
+ read this
+ }
+ value (N) {
+ stack .s {
+ if len(.s)=.m then drop
+ data N
+ }
+ = array(stack(.s))#sum()/len(.s)
+ }
+ class:
+ module smaMaker (.m) {
+ }
+ }
+ Print "Period = 3"
+ ma=smaMaker(3)
+ test(0, 9)
+ Print "Period = 5"
+ ma=smaMaker(5)
+ test(9, 0)
+ end
+ sub test(A, B)
+ local i
+ Print
+ for i=A to B
+ Print "Add ";i;" => moving average ";ma(i)
+ next
+ Print
+ end sub
+}
+Simple_moving_average
diff --git a/Task/Babbage-problem/EDSAC-order-code/babbage-problem.edsac b/Task/Babbage-problem/EDSAC-order-code/babbage-problem.edsac
index 3189034b85..1240f20d03 100644
--- a/Task/Babbage-problem/EDSAC-order-code/babbage-problem.edsac
+++ b/Task/Babbage-problem/EDSAC-order-code/babbage-problem.edsac
@@ -26,12 +26,13 @@ Here, the last character sets the teleprinter to figures.]
[4] PF PF [1st difference for n^2]
[Constants]
+[2024-12-25 Load time: clear each 35-bit constant, including sandwich bit]
+ T6#ZPF T8#ZPF T10#ZPF T12#ZPF
+[Then resume normal loading at first 35-bit constant]
+ T6Z
[6] P64F PF [2nd difference for n^2, i.e. 128]
[8] P4F PF [1st difference for n, i.e. 8]
- T10#Z PF T10Z [clears sandwich digit between 10 and 11;
- cf. Wilkes, Wheeler & Gill, 1951, pp 110, 141-2]
[10] #1760F V2046F [-1000000]
- T12#Z PF T12Z [clears sandwich digit between 12 and 13]
[12] Q1728F PD [269696]
[14] &F [line feed]
[15] @F [carriage return]
diff --git a/Task/Babbage-problem/M2000-Interpreter/babbage-problem.m2000 b/Task/Babbage-problem/M2000-Interpreter/babbage-problem.m2000
index 1dcd8795e0..db574a7240 100644
--- a/Task/Babbage-problem/M2000-Interpreter/babbage-problem.m2000
+++ b/Task/Babbage-problem/M2000-Interpreter/babbage-problem.m2000
@@ -1,6 +1,14 @@
-Def Long k=1000000, T=269696, n
+long long k=1000000, T=269696, n
+boolean first=true
+Document doc$
n=Sqrt(269696)
For n=n to k {
- If n^2 mod k = T Then Exit
+ If n^2&& mod k = T Then
+ doc$=format$("The "+if$(first->"smallest", "next")+" number whose square ends in {0} is {1}, Its square is {2}", T, n, n**2&&)+{
+ }
+ first=false
+ refresh
+ end if
}
-Report format$("The smallest number whose square ends in {0} is {1}, Its square is {2}", T, n, n**2)
+clipboard doc$
+report doc$
diff --git a/Task/Babbage-problem/PascalABC.NET/babbage-problem.pas b/Task/Babbage-problem/PascalABC.NET/babbage-problem.pas
new file mode 100644
index 0000000000..e8c2ecff0e
--- /dev/null
+++ b/Task/Babbage-problem/PascalABC.NET/babbage-problem.pas
@@ -0,0 +1,9 @@
+//the smallest positive integer whose square ends in the digits 269,696
+## var k:=269696;
+var n:=trunc(sqrt(k));(* Start with n *)
+if n mod 2<>0 then n-=1;(* n:=n-1 *)
+ repeat
+ n += 2 (* Increase n by 2. n:=n+2 *)
+ until (n * n) mod 1000000 = 269696;
+$'The smallest positive integer is {n} whose square ends in {k}'.println;
+$'{n}² = {n*n}'.println;
diff --git a/Task/Bell-numbers/BQN/bell-numbers.bqn b/Task/Bell-numbers/BQN/bell-numbers.bqn
new file mode 100644
index 0000000000..918f1357ad
--- /dev/null
+++ b/Task/Bell-numbers/BQN/bell-numbers.bqn
@@ -0,0 +1,8 @@
+Bell ← {(+`⊢´⊸∾)⍟(↕𝕩)⋈1}
+
+•Out "First 15 Bell numbers:"
+•Show ⊑¨ Bell 15
+
+•Out ""
+•Out "First 10 rows of the Bell triangle:"
+•Show¨ Bell 10
diff --git a/Task/Bell-numbers/Forth/bell-numbers.fth b/Task/Bell-numbers/Forth/bell-numbers.fth
new file mode 100644
index 0000000000..6b7c8259fa
--- /dev/null
+++ b/Task/Bell-numbers/Forth/bell-numbers.fth
@@ -0,0 +1,51 @@
+: triangle-allocate ( u -- addr )
+ dup 1+ * 2/ cells dup
+ allocate abort" out of memory"
+ tuck swap erase ;
+
+: triangle-deallocate ( addr -- )
+ free abort" memory deallocation error" ;
+
+: triangle-row-address ( addr u -- addr )
+ dup 1+ * 2/ cells + ;
+
+: bell-triangle-row ( addr u -- )
+ tuck 1- triangle-row-address
+ 2dup swap cells +
+ dup 1 cells - @ over !
+ rot 0 ?do
+ dup @ >r over @ r> + >r
+ cell+ r> over !
+ swap cell+ swap
+ loop 2drop ;
+
+: bell-triangle ( u -- addr )
+ dup triangle-allocate
+ dup 1 swap !
+ swap 1 ?do
+ dup i bell-triangle-row
+ loop ;
+
+: print-bell-numbers ( addr u -- )
+ 0 ?do
+ dup i triangle-row-address @ . cr
+ loop drop ;
+
+: print-bell-row ( addr u -- )
+ tuck triangle-row-address swap
+ 1+ 0 ?do
+ dup @ . cell+
+ loop drop cr ;
+
+: main ( -- )
+ 15 bell-triangle
+ ." First 15 Bell numbers:" cr
+ dup 15 print-bell-numbers cr
+ ." First 10 rows of the Bell triangle:" cr
+ 10 0 do
+ dup i print-bell-row
+ loop
+ triangle-deallocate ;
+
+main
+bye
diff --git a/Task/Bell-numbers/Haskell/bell-numbers-5.hs b/Task/Bell-numbers/Haskell/bell-numbers-5.hs
new file mode 100644
index 0000000000..2574f2daa3
--- /dev/null
+++ b/Task/Bell-numbers/Haskell/bell-numbers-5.hs
@@ -0,0 +1,17 @@
+import Data.Ratio ((%), numerator)
+
+infixl 7 *.
+(*.) :: Num a => a -> [a] -> [a]
+x *. (p:ps) = x*p : x*.ps
+
+instance Num a => Num [a] where
+ negate = map negate
+ (+) = zipWith (+)
+ (*) (p:ps) (q:qs) = p*q : ((p*.qs) + ps*(q:qs))
+ fromInteger n = fromInteger n:repeat 0
+
+instance (Eq a, Fractional a) => Fractional [a] where
+ (/) (0:ps) (0:qs) = ps/qs
+ (/) (p:ps) (q:qs) = let r=p/q in r : (ps - r*.qs)/(q:qs)
+
+ fromRational q = fromRational q:repeat 0
diff --git a/Task/Bell-numbers/Haskell/bell-numbers-6.hs b/Task/Bell-numbers/Haskell/bell-numbers-6.hs
new file mode 100644
index 0000000000..1cccede973
--- /dev/null
+++ b/Task/Bell-numbers/Haskell/bell-numbers-6.hs
@@ -0,0 +1,2 @@
+expseq :: [Rational] -> [Rational]
+expseq ps = zipWith (\p q -> p*fromInteger q) ps (scanl (*) 1 [1..])
diff --git a/Task/Bell-numbers/Haskell/bell-numbers-7.hs b/Task/Bell-numbers/Haskell/bell-numbers-7.hs
new file mode 100644
index 0000000000..e6c2d50d9c
--- /dev/null
+++ b/Task/Bell-numbers/Haskell/bell-numbers-7.hs
@@ -0,0 +1,3 @@
+infixr 9 |>
+(|>) :: (Eq a, Num a) => [a] -> [a] -> [a]
+(p:ps) |> (0:qs) = p : qs*(ps |> (0:qs))
diff --git a/Task/Bell-numbers/Haskell/bell-numbers-8.hs b/Task/Bell-numbers/Haskell/bell-numbers-8.hs
new file mode 100644
index 0000000000..9cc115db88
--- /dev/null
+++ b/Task/Bell-numbers/Haskell/bell-numbers-8.hs
@@ -0,0 +1,11 @@
+exp1 :: [Rational]
+exp1 = 0 : map (1%) factorials
+ where
+ factorials = scanl (*) 1 [2..]
+
+exps :: [Rational]
+exps = 1 : zipWith (*) exps [ 1%n | n <- [1..] ]
+
+bell :: [Integer]
+bell = map numerator
+ (expseq (exps |> exp1))
diff --git a/Task/Bell-numbers/Haskell/bell-numbers-9.hs b/Task/Bell-numbers/Haskell/bell-numbers-9.hs
new file mode 100644
index 0000000000..11d50b5761
--- /dev/null
+++ b/Task/Bell-numbers/Haskell/bell-numbers-9.hs
@@ -0,0 +1,4 @@
+ghci> take 15 bell
+[1,1,2,5,15,52,203,877,4140,21147,115975,678570,4213597,27644437,190899322]
+ghci> bell !! 49
+10726137154573358400342215518590002633917247281
diff --git a/Task/Bell-numbers/Miranda/bell-numbers.miranda b/Task/Bell-numbers/Miranda/bell-numbers.miranda
new file mode 100644
index 0000000000..67a573f599
--- /dev/null
+++ b/Task/Bell-numbers/Miranda/bell-numbers.miranda
@@ -0,0 +1,16 @@
+main :: [sys_message]
+main = [Stdout "First 15 and 50th Bell numbers:\n",
+ Stdout (lay [(rjustify 2 (show i)) ++ ": " ++ show (bell_numbers ! i)
+ | i <- [1..15] ++ [50]]),
+ Stdout "\nFirst 10 rows of the Bell triangle:\n",
+ Stdout (lay [concat [rjustify 7 (show n) | n <- row]
+ | row <- take 10 bell_triangle])
+ ]
+
+
+bell_numbers :: [num]
+bell_numbers = map last bell_triangle
+
+bell_triangle :: [[num]]
+bell_triangle = iterate bell_step [1]
+ where bell_step row = scan (+) (last row) row
diff --git a/Task/Bell-numbers/PARI-GP/bell-numbers.parigp b/Task/Bell-numbers/PARI-GP/bell-numbers.parigp
new file mode 100644
index 0000000000..f62bf25259
--- /dev/null
+++ b/Task/Bell-numbers/PARI-GP/bell-numbers.parigp
@@ -0,0 +1,4 @@
+genit(maxx=50)={bell=List();
+for(n=0,maxx,q=sum(k=0,n,stirling(n,k,2));
+listput(bell,q));bell}
+END
diff --git a/Task/Bell-numbers/Refal/bell-numbers.refal b/Task/Bell-numbers/Refal/bell-numbers.refal
new file mode 100644
index 0000000000..f65c59ce11
--- /dev/null
+++ b/Task/Bell-numbers/Refal/bell-numbers.refal
@@ -0,0 +1,41 @@
+$ENTRY Go {
+ , : e.Bell (e.B50)
+ , : (e.F15) e.Rest
+ =
+
+ >;
+}
+
+Show {
+ (e.X) = >;
+};
+
+BellNumbers {
+ s.N, : e.Rows = ;
+};
+
+BellTriangle {
+ s.N = ((1))>;
+ 0 e.T = e.T;
+ s.N e.Rs (e.R) = e.Rs (e.R) ()>;
+};
+
+BellStep {
+ e.Row, e.Row: e.X (e.Last) = ;
+};
+
+Rsum {
+ (Acc e.Acc) = ;
+ (Acc e.Acc) (e.N) e.Ns, : e.N2 =
+ (e.N2) ;
+ e.Ns = ;
+};
+
+Each {
+ (e.F) = ;
+ (e.F) (e.X) e.Xs = () ;
+};
+
+Head {
+ t.X e.Y = t.X;
+};
diff --git a/Task/Bell-numbers/SETL/bell-numbers.setl b/Task/Bell-numbers/SETL/bell-numbers.setl
new file mode 100644
index 0000000000..83c7ca45d4
--- /dev/null
+++ b/Task/Bell-numbers/SETL/bell-numbers.setl
@@ -0,0 +1,31 @@
+program bell_numbers;
+ print("First 15 and 50th Bell numbers:");
+ b := bell_nums(50);
+ loop for i in [1..15] with 50 do
+ print(lpad(str i, 2) + ": " + str b(i));
+ end loop;
+
+ print;
+ print("First 10 rows of the Bell triangle:");
+ loop for row in bell_triangle(10) do
+ print(+/[lpad(str n, 7) : n in row]);
+ end loop;
+
+ proc bell_nums(n);
+ tri := bell_triangle(n);
+ return [row(#row) : row in tri];
+ end proc;
+
+ proc bell_triangle(rows);
+ tri := [[1]];
+ loop for i in [2..rows] do
+ row := tri(#tri);
+ nextrow := [row(#row)];
+ loop for n in row do
+ nextrow with:= nextrow(#nextrow) + n;
+ end loop;
+ tri with:= nextrow;
+ end loop;
+ return tri;
+ end proc;
+end program;
diff --git a/Task/Benfords-law/Quackery/benfords-law.quackery b/Task/Benfords-law/Quackery/benfords-law.quackery
new file mode 100644
index 0000000000..c18ea50a99
--- /dev/null
+++ b/Task/Benfords-law/Quackery/benfords-law.quackery
@@ -0,0 +1,36 @@
+ [ $ "bigrat.qky" loadfile ] now!
+
+ [ ' [ 1 1 ]
+ swap 2 - times
+ [ dup -1 peek
+ over -2 peek
+ + join ] ] is fibonacci ( n --> [ )
+
+ [ 0 swap witheach + ] is sum ( [ --> n )
+
+ [ [ 10 /mod over while
+ drop again ] nip ] is msd ( n --> n )
+
+ [ 2dup peek 1+ unrot poke ] is tallydigit ( [ n --> [ )
+
+ [ 0 10 of swap
+ witheach
+ [ msd tallydigit ] ] is msdcount ( [ --> [ )
+
+ [ [ table
+ $ "0.30103" $ "0.17609"
+ $ "0.12494" $ "0.09691"
+ $ "0.07918" $ "0.06695"
+ $ "0.05799" $ "0.05115"
+ $ "0.04576" ] do echo$ ] is expected ( --> )
+
+ say "n expected counted" cr
+ 1000 fibonacci msdcount
+ behead drop
+ dup sum swap
+ witheach
+ [ i^ 1+ echo sp sp
+ i^ expected sp sp
+ over reduce
+ 5 point$ echo$ cr ]
+ drop
diff --git a/Task/Bifid-cipher/Go/bifid-cipher.go b/Task/Bifid-cipher/Go/bifid-cipher.go
new file mode 100644
index 0000000000..c8a6cfa6fe
--- /dev/null
+++ b/Task/Bifid-cipher/Go/bifid-cipher.go
@@ -0,0 +1,180 @@
+/*
+ Only use ASCII letters between A and Z or the Characters in square... . If the row with 'J' is removed from the squares,
+ then the square is a 'Polybios square' and you must use removeSpaceI(text) to encrypt and decrypt
+*/
+package main
+
+import (
+ "fmt"
+ "strings"
+)
+
+var (
+ squareRosetta [][]byte = [][]byte{ //rosettacode
+ {'A', 'B', 'C', 'D', 'E'},
+ {'F', 'G', 'H', 'I', 'K'},
+ {'L', 'M', 'N', 'O', 'P'},
+ {'Q', 'R', 'S', 'T', 'U'},
+ {'V', 'W', 'X', 'Y', 'Z'},
+ {'J', '1', '2', '3', '4'},
+ }
+
+ squareWikipedia [][]byte = [][]byte{ // wikipedia
+
+ {'B', 'G', 'W', 'K', 'Z'},
+ {'Q', 'P', 'N', 'D', 'S'},
+ {'I', 'O', 'A', 'X', 'E'},
+ {'F', 'C', 'L', 'U', 'M'},
+ {'T', 'H', 'Y', 'V', 'R'},
+ {'J', '1', '2', '3', '4'},
+ }
+
+ textRosetta string = "0ATTACKATDAWN"
+ textRosettaEncoded string = "DQBDAXDQPDQH" // only for test
+ textWikipedia string = "FLEEATONCE"
+ textWikipediaEncoded string = "UAEOLWRINS" // only for test
+ textTest string = "The invasion will start on the first of January"
+ textTextEncoded string = "RASOAQXFIOORXESXADETSWLTNIAZQOISBRGBALY" // only for test
+)
+
+type koord struct {
+ X byte
+ Y byte
+}
+
+func (k *koord) LessThen(other *koord) bool {
+ if k.Y > other.Y {
+ return false
+ }
+ if k.Y < other.Y {
+ return true
+ }
+ if k.X < other.X {
+ return true
+ }
+ return false
+}
+
+func (k *koord) EqualTo(other koord) bool {
+ if k.X == other.X && k.Y == other.Y {
+ return true
+ }
+ return false
+}
+
+var encryptMap map[byte]koord
+var decryptMap map[koord]byte
+
+func squareToMaps(square [][]byte) (map[byte]koord, map[koord]byte) {
+ eMap := make(map[byte]koord)
+ dMap := make(map[koord]byte)
+ for x, col := range square {
+ for y, v := range col {
+ eMap[v] = koord{byte(x), byte(y)}
+ dMap[koord{byte(x), byte(y)}] = v
+
+ }
+ }
+ return eMap, dMap
+}
+
+func removeSpaceI(text string) string {
+ var n string
+ s := strings.ToUpper(text)
+ for _, b := range []byte(s) {
+ //use only ASCII Characters from A to Z
+ if b < 'A' || b > 'Z' {
+ continue
+ }
+ if b == 'J' {
+ b = 'I'
+ }
+ n = n + string(b)
+ }
+ return n
+}
+
+func removeSpace(text string, square map[byte]koord) string {
+ var n string
+ //to UpperCase and then remove all Spaces an Characters witch are not in square
+ s := strings.ReplaceAll(strings.ToUpper(text), " ", "")
+ for _, b := range []byte(s) {
+ _, ok := square[b]
+ if ok {
+ n = n + string(b)
+ }
+ }
+ return n
+}
+
+func encrypt(text string, emap map[byte]koord, dmap map[koord]byte) string {
+ text = removeSpace(text, emap)
+ var row0, row1 []byte
+ for _, b := range []byte(text) {
+ xy := emap[b]
+ row0 = append(row0, xy.X)
+ row1 = append(row1, xy.Y)
+ }
+ row0 = append(row0, row1...)
+
+ var s string
+ for i := 0; i < len(row0); i += 2 {
+ s = s + string(dmap[koord{row0[i], row0[i+1]}])
+ }
+ return s
+}
+
+func decrypt(text string, emap map[byte]koord, dmap map[koord]byte) string {
+ text = removeSpace(text, emap)
+ k := make([]koord, len(text))
+
+ for i, b := range []byte(text) {
+ k[i] = emap[b]
+ }
+
+ kl := make([]byte, len(k)*2)
+ i := int(0)
+ for _, ki := range k {
+ kl[i] = ki.X
+ kl[i+1] = ki.Y
+ i += 2
+ }
+ l := len(kl) / 2
+ k1 := kl[:l]
+ k2 := kl[l:]
+ var s string
+
+ for i := 0; i < l; i++ {
+ s = s + string(dmap[koord{k1[i], k2[i]}])
+ }
+ return s
+}
+
+func main() {
+
+ encryptMap, decryptMap = squareToMaps(squareRosetta)
+ fmt.Println("from Rosettacode")
+ fmt.Println("original:\t", textRosetta)
+ s := encrypt(textRosetta, encryptMap, decryptMap)
+ fmt.Println("codiert:\t", s)
+ s = decrypt(s, encryptMap, decryptMap)
+ fmt.Println("and back:\t", s)
+
+ fmt.Println("from Wikipedia")
+ encryptMap, decryptMap = squareToMaps(squareWikipedia)
+ fmt.Println("original:\t", textWikipedia)
+ s = encrypt(textWikipedia, encryptMap, decryptMap)
+ fmt.Println("codiert:\t", s)
+ s = decrypt(s, encryptMap, decryptMap)
+ fmt.Println("and back:\t", s)
+
+ encryptMap, decryptMap = squareToMaps(squareWikipedia)
+ fmt.Println("from Rosettacode long part")
+ fmt.Println("original:\t", textTest)
+ s = encrypt(textTest, encryptMap, decryptMap)
+ fmt.Println("codiert:\t", s)
+ // Wenn der Text eine ungerade Anzahl Buchstaben hat, funktioniert der Algorithmus nicht!!!
+ s = decrypt(s, encryptMap, decryptMap)
+ fmt.Println("and back:\t", s)
+
+}
diff --git a/Task/Bifid-cipher/Haskell/bifid-cipher.hs b/Task/Bifid-cipher/Haskell/bifid-cipher.hs
new file mode 100644
index 0000000000..9964f7aa9d
--- /dev/null
+++ b/Task/Bifid-cipher/Haskell/bifid-cipher.hs
@@ -0,0 +1,60 @@
+import Data.List
+import Data.Char
+
+-- Defining all the grids I'll be using in one go.
+
+rcBifid = [
+ 'A','B','C','D','E',
+ 'F','G','H','I','K',
+ 'L','M','N','O','P',
+ 'Q','R','S','T','U',
+ 'V','W','X','Y','Z'
+ ] -- We will use strings here onwards. This was just a demonstration.
+
+wikiBifid = "POLYBIUSCHERADFGKMNQTVWXZ"
+cmiBifid = "CMIHASKELQWRTYUOPDFGZXVBN"
+
+-- Convert a character to its grid coordinates (1-based index)
+chr2pair square x = if x == 'J' then chr2pair square 'I' else case elemIndex x square of
+ Nothing -> error "char is not in cipher grid"
+ Just a -> (\(x,y) -> (x+1,y+1)) (divMod a 5) -- Convert flat index to (row, col)
+
+pair2chr square (x,y) = square !! ((x-1)*5+y-1)
+
+-- Pairs up elements from a list, used in Bifid encoding process
+pairUp :: [a] -> [(a,a)]
+pairUp [] = []
+pairUp [a] = error "Odd number of elements"
+pairUp (x:y:ys) = (x,y):(pairUp ys)
+
+encrypt square message = map (pair2chr square) (pairUp (l ++ r)) where
+ (l,r) = unzip $ map (chr2pair square) message
+
+decrypt square message = map (pair2chr square) (zip u d) where
+ (u,d) = splitAt (length message) $ concatMap (\(x,y) -> [x,y]) $ map (chr2pair square) message
+
+main = do
+ let
+ message1 = "ATTACKATDAWN"
+ message2 = "FLEEATONCE"
+ encrypt1 = encrypt rcBifid message1
+ encrypt2 = encrypt wikiBifid message2
+ encrypt3 = encrypt wikiBifid message1
+ myMessage = "The invasion will start on the first of January"
+ encrypt4 = encrypt cmiBifid $ map toUpper $ filter (/= ' ') myMessage -- Remove spaces, uppercase
+
+ putStrLn $ "Message 1: " ++ message1
+ putStrLn $ "Encryption wrt RC's square: " ++ encrypt1
+ putStrLn $ "Decrypt: " ++ show (decrypt rcBifid encrypt1)
+
+ putStrLn $ "Message 2: " ++ message2
+ putStrLn $ "Encryption wrt Wiki's square: " ++ encrypt2
+ putStrLn $ "Decrypt: " ++ show (decrypt wikiBifid encrypt2)
+
+ putStrLn $ "Message 3: " ++ message1
+ putStrLn $ "Encryption wrt Wiki's square: " ++ encrypt3
+ putStrLn $ "Decrypt: " ++ show (decrypt wikiBifid encrypt3)
+
+ putStrLn $ "Message 4: " ++ myMessage
+ putStrLn $ "Encryption wrt CMI square: " ++ encrypt4
+ putStrLn $ "Decrypt: " ++ show (decrypt cmiBifid encrypt4)
diff --git a/Task/Bifid-cipher/M2000-Interpreter/bifid-cipher.m2000 b/Task/Bifid-cipher/M2000-Interpreter/bifid-cipher.m2000
new file mode 100644
index 0000000000..67d507af7a
--- /dev/null
+++ b/Task/Bifid-cipher/M2000-Interpreter/bifid-cipher.m2000
@@ -0,0 +1,68 @@
+module Bifid_cipher (f, code$) {
+ n=sqrt(len(code$))
+ print #f," ";
+ for i=1 to n
+ print #f, i+" ";
+ next
+ print #f
+ for i=0 to n-1
+ Print #f, (i+1)+" "+STR$(mid$(code$,1+i*n, n),STRING$("@ ", 5))
+ next
+ tables=lambda (a$)->{
+ n=sqrt(len(a$))
+ a=list
+ for i=1 to len(a$)
+ append a, mid$(a$,i, 1):=((i-1) mod n+1, (i-1) div n+1 )
+ next
+ b=list
+ m=each(a)
+ while m
+ z=eval(m)
+ append b, z#val$(1)+z#val$(0):=eval$(m!)
+ end while
+ =a, b
+ }(code$)
+ encode= lambda (a, b)->{
+ =lambda a,b (mess as string) -> {
+ document code$
+ for n=1 to 0
+ for i=1 to len(mess)
+ q=mid$(mess, i,1)
+ if not exist(a, q) then
+ if q="J" then q="I" else q="A"
+ end if
+ code$=a(q)#val$(n)
+ next
+ next
+ document final$
+ for i=1 to len(code$) step 2
+ final$=b$(mid$(code$, i, 2))
+ next
+ = final$
+ }
+ }(!tables)
+ decode= lambda (a, b)->{
+ =lambda a,b (final as string) -> {
+ document code$, mess$
+ for i=1 to len(final)
+ q=a(mid$(final, i, 1))
+ code$=q#val$(1)+q#val$(0)
+ next
+ offset=len(code$) div 2
+ for i=1 to offset
+ mess$=b$(mid$(code$,i,1)+mid$(code$,i+offset,1))
+ next
+ = mess$
+ }
+ }(!tables)
+ Print #f, encode("ATTACKATDAWN")
+ Print #f, decode(encode("ATTACKATDAWN"))="ATTACKATDAWN"
+ Print #f, encode(ucase$(filter$("The invasion will start on the first of January", " ")))
+ Print #f, decode(encode(ucase$(filter$("The invasion will start on the first of January", " "))))
+}
+open "out.txt" for output as #a
+Bifid_cipher a, "ABCDEFGHIKLMNOPQRSTUVWXYZ"
+Bifid_cipher a, "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
+Bifid_cipher a, "BGWKZQPNDSIOAXEFCLUMTHYVR"
+close #a
+win "out.txt"
diff --git a/Task/Binary-digits/Zig/binary-digits.zig b/Task/Binary-digits/Zig/binary-digits.zig
new file mode 100644
index 0000000000..8b207ca0b0
--- /dev/null
+++ b/Task/Binary-digits/Zig/binary-digits.zig
@@ -0,0 +1,7 @@
+const std = @import("std");
+
+pub fn main() void {
+ for(0..10) |i| {
+ std.debug.print("{b}\n", .{i});
+ }
+}
diff --git a/Task/Binary-strings/Free-Pascal-Lazarus/binary-strings.pas b/Task/Binary-strings/Free-Pascal-Lazarus/binary-strings.pas
new file mode 100644
index 0000000000..7a8bb08035
--- /dev/null
+++ b/Task/Binary-strings/Free-Pascal-Lazarus/binary-strings.pas
@@ -0,0 +1,31 @@
+uses sysutils;
+var
+ { declaration is creation }
+ a,b:string;
+ { creation with default value }
+ c:string = 'this is a string';
+begin
+ { assignment }
+ a := 'test';
+ b := 'test';
+ writeln(a:6, b:6);
+ { comparison }
+ writeln('equal? ', a = b );
+ { empty string }
+ writeln('empty? ', a = '');
+ { cloning, copying }
+ a := c;
+ writeln('copy c to a, a is now: ', a);
+ { append }
+ b := b +'W';
+ writeln('append W to b: ',b);
+ { extract substring }
+ b := copy(a,6,2);
+ writeln('this should be is": ',b);
+ { replace }
+ a := stringreplace(a,'i','I',[rfReplaceAll]);
+ writeln('replace i with I: ',a);
+ { join }
+ a:= concat(b,c);
+ writeln('join b and c; ',a);
+end.
diff --git a/Task/Binary-strings/M2000-Interpreter/binary-strings.m2000 b/Task/Binary-strings/M2000-Interpreter/binary-strings.m2000
new file mode 100644
index 0000000000..02751bf64b
--- /dev/null
+++ b/Task/Binary-strings/M2000-Interpreter/binary-strings.m2000
@@ -0,0 +1,51 @@
+' String assignment
+a$="alfa"
+string a="beta"
+b="beta too"
+all=a$+a+b
+Print All
+' String comparison
+Print a$=a, a=b, a+A+" too"+a$=a+b+a$ ' false false true
+b$=a$
+// compare return 0 for equal (-1,0, 1),
+//same as <=> but compare work with variables only (without coping values)
+print "using compare", compare(a$, b$), a$<=>b$ ' 0 0
+' String cloning and copying
+a2$=a$ ' copy
+' Check if a string is empty
+print a2$="", len(a$)=0
+' Append a byte to a string
+c$=Str$("ABCDE") ' utf16le "ABCDE" convert to ANSI (one byte per code)
+Print len(c$)=2.5 ' measure 16bit, so we get 2.5x2=5 bytes
+c$+=Str$("Z")
+Print Len(c$)=3
+Print chr$(c$)="ABCDEZ" ' convert to UTF16LE and then compare
+' Extract a substring from a string
+Print chr$(mid$(c$,2, 2 as byte))="BC"
+Print mid$("ABCDEZ",2,2) ="BC"
+' Replace every occurrence of a byte (or a string) in a string with another string
+Print Replace$("BC", "?", "ABCDEZBC")="A?DEZ?"
+Print Replace$("BC", "?", CHR$(c$))="A?DEZ"
+' String creation and destruction (using buffers. Memory Blocks)
+' (when needed and if there's no garbage collection or similar mechanism)
+'Join strings (IN A BUFFRT)
+buffer clear K as byte*10 ' using clear to erase the buffer with 0
+Return K, 0:=c$
+Print eval(k, 2)=asc("C"), eval(k, 3)=asc("D")
+Return k, 2:=str$("KL")
+Print chr$(eval$(k, 0, 6))="ABKLEZ"
+' rotate one byte
+M= eval(K,0)
+return k, 0:=eval$(k, 1, 5), 5:=m ' we can place strings or bytes at specific index - from 0.
+Print chr$(eval$(k, 0, 6))="BKLEZA" ' true
+// change length of buffer
+buffer K as byte*6
+// now we get the full string (with the length of 6 bytes)
+Print chr$(eval$(k))="BKLEZA" ' true
+buffer K1 as byte*6
+// buffers are special objects, so we have strings refering by object pointer.
+// we can pass the buffer pointer or return it from a function, also we can swap variables for buffers
+swap K, k1
+Print chr$(eval$(k1))="BKLEZA" ' true
+// we can get the address of string:
+Print k1(0) ' return the absolute address of byte at offset 0 on k1 buffer
diff --git a/Task/Binary-strings/Sidef/binary-strings.sidef b/Task/Binary-strings/Sidef/binary-strings.sidef
new file mode 100644
index 0000000000..9f9f66c290
--- /dev/null
+++ b/Task/Binary-strings/Sidef/binary-strings.sidef
@@ -0,0 +1,48 @@
+# string creation
+var x = "hello world"
+
+# string destruction
+x = nil
+
+# string assignment with a null byte
+x = "a\0b"
+say x.length # ==> 3
+
+# string comparison
+if (x == "hello") {
+ say "equal"
+} else {
+ say "not equal"
+}
+
+var y = 'bc'
+if (x < y) {
+ say "#{x} is lexicographically less than #{y}"
+}
+
+# string cloning
+var xx = x.clone
+say (x == xx) # true, same length and content
+say (x.refaddr == xx.refaddr) # false, different objects
+
+# check if empty
+if (x.is_empty) {
+ say "is empty"
+}
+
+# append a byte
+x += "\07"
+say x.dump #=> "a\0b\a"
+
+# substring
+say x.substr(0, -1).dump #=> "a\0b"
+
+# replace bytes
+say "hello world".tr("l", "L")
+
+# join strings
+var a = "hel"
+var b = "lo w"
+var c = "orld"
+var d = (a + b + c)
+say d
diff --git a/Task/Bioinformatics-base-count/C/bioinformatics-base-count-1.c b/Task/Bioinformatics-base-count/C/bioinformatics-base-count-1.c
deleted file mode 100644
index 40a842e9b5..0000000000
--- a/Task/Bioinformatics-base-count/C/bioinformatics-base-count-1.c
+++ /dev/null
@@ -1,115 +0,0 @@
-#include
-#include
-#include
-
-typedef struct genome{
- char* strand;
- int length;
- struct genome* next;
-}genome;
-
-genome* genomeData;
-int totalLength = 0, Adenine = 0, Cytosine = 0, Guanine = 0, Thymine = 0;
-
-int numDigits(int num){
- int len = 1;
-
- while(num>10){
- num = num/10;
- len++;
- }
-
- return len;
-}
-
-void buildGenome(char str[100]){
- int len = strlen(str),i;
- genome *genomeIterator, *newGenome;
-
- totalLength += len;
-
- for(i=0;istrand = (char*)malloc(len*sizeof(char));
- strcpy(genomeData->strand,str);
- genomeData->length = len;
-
- genomeData->next = NULL;
- }
-
- else{
- genomeIterator = genomeData;
-
- while(genomeIterator->next!=NULL)
- genomeIterator = genomeIterator->next;
-
- newGenome = (genome*)malloc(sizeof(genome));
-
- newGenome->strand = (char*)malloc(len*sizeof(char));
- strcpy(newGenome->strand,str);
- newGenome->length = len;
-
- newGenome->next = NULL;
- genomeIterator->next = newGenome;
- }
-}
-
-void printGenome(){
- genome* genomeIterator = genomeData;
-
- int width = numDigits(totalLength), len = 0;
-
- printf("Sequence:\n");
-
- while(genomeIterator!=NULL){
- printf("\n%*d%3s%3s",width+1,len,":",genomeIterator->strand);
- len += genomeIterator->length;
-
- genomeIterator = genomeIterator->next;
- }
-
- printf("\n\nBase Count\n----------\n\n");
-
- printf("%3c%3s%*d\n",'A',":",width+1,Adenine);
- printf("%3c%3s%*d\n",'T',":",width+1,Thymine);
- printf("%3c%3s%*d\n",'C',":",width+1,Cytosine);
- printf("%3c%3s%*d\n",'G',":",width+1,Guanine);
- printf("\n%3s%*d\n","Total:",width+1,Adenine + Thymine + Cytosine + Guanine);
-
- free(genomeData);
-}
-
-int main(int argc,char** argv)
-{
- char str[100];
- int counter = 0, len;
-
- if(argc!=2){
- printf("Usage : %s \n",argv[0]);
- return 0;
- }
-
- FILE *fp = fopen(argv[1],"r");
-
- while(fscanf(fp,"%s",str)!=EOF)
- buildGenome(str);
- fclose(fp);
-
- printGenome();
-
- return 0;
-}
diff --git a/Task/Bioinformatics-base-count/C/bioinformatics-base-count-2.c b/Task/Bioinformatics-base-count/C/bioinformatics-base-count.c
similarity index 100%
rename from Task/Bioinformatics-base-count/C/bioinformatics-base-count-2.c
rename to Task/Bioinformatics-base-count/C/bioinformatics-base-count.c
diff --git a/Task/Bioinformatics-base-count/M2000-Interpreter/bioinformatics-base-count.m2000 b/Task/Bioinformatics-base-count/M2000-Interpreter/bioinformatics-base-count.m2000
new file mode 100644
index 0000000000..ad0dda3e8e
--- /dev/null
+++ b/Task/Bioinformatics-base-count/M2000-Interpreter/bioinformatics-base-count.m2000
@@ -0,0 +1,39 @@
+Module Bioinformatics_base_count (f){
+ a$={
+ CGTAAAAAATTACAACGTCCTTTGGCTATCTCTTAAACTCCTGCTAAATG
+ CTCGTGCTTTCCAATTATGTAAGCGTTCCGAGACGGGGTGGTCGATTCTG
+ AGGACAAAGGTCAAGATGGAGCGCATCGAACGCAATAAGGATCATTTGAT
+ GGGACGTTTCGTCGACAAAGTCTTGTTTCGAGAGTAACGGCTACCGTCTT
+ CGATTCTGCTTATAACACTATGTTCTTATGAAATGGATGTTCTGAGTTGG
+ TCAGTCCCAATGTGCGGGGTTTCTTTTAGTACGTCGGGAGTGGTATTATA
+ TTTAATTTTTCTATATAGCGATCTGTATTTAAGCAATTCATTTAGGTTAT
+ CGCCGCGATGCTCGGTTCGGACCGCCAAGCATCTGGCTCCACTGCTAGTG
+ TCCTAAATTTGAATGGCAAACACAAATAAGATTTAGCAATTCGTGTAGAC
+ GACCGGGGACTTGCATGATGGGAGCAGCTTTGTTAAACTACGAACGTAAT
+ }
+ Data "A", "C","G","T"
+ a$=filter$(a$," "+chr$(13)+chr$(10)+chr$(9))
+ tot=len(a$)
+ k=1
+ print #f, "SEQUENCE:"
+ for i=50 to len(a$) step 50
+ Print #f, str$(k,"000: ");mid$(a$, k, 50)
+ k=i
+ next
+ Print #f, "BASECOUNT:"
+ while not empty
+ read t$
+ b$=filter$(a$, t$)
+ Print #f, " "+t$+": ";len(a$)-len(b$)
+ swap a$, b$
+ end while
+ Print #f, "Tot:";tot
+}
+
+open "" for wide output as #f
+Bioinformatics_base_count f
+close #f
+open "outtext.txt" for wide output as #f
+Bioinformatics_base_count f
+close #f
+win "outtext.txt"
diff --git a/Task/Biorhythms/C/biorhythms-2.c b/Task/Biorhythms/C/biorhythms-2.c
index 3e2d9d0f69..ddd8256686 100644
--- a/Task/Biorhythms/C/biorhythms-2.c
+++ b/Task/Biorhythms/C/biorhythms-2.c
@@ -3,3 +3,4 @@ gcc -o cbio cbio.c -lm
Age: 10717 days
Physical cycle: -27%
Emotional cycle: -100%
+Intellectual cycle: -100%
diff --git a/Task/Biorhythms/M2000-Interpreter/biorhythms.m2000 b/Task/Biorhythms/M2000-Interpreter/biorhythms.m2000
index 8b4a33c778..732e4e600f 100644
--- a/Task/Biorhythms/M2000-Interpreter/biorhythms.m2000
+++ b/Task/Biorhythms/M2000-Interpreter/biorhythms.m2000
@@ -1,24 +1,21 @@
-Module Biorhythms {
- form 80
- enum bio {Physical=23, Emotional=28,Mental=33}
- quadrants=(("up and rising", "peak"), ("up but falling", "transition"), ("down and falling", "valley"), ("down but rising", "transition"))
- date birth="1943-03-09"
- date bioDay="1972-07-11", transition
- for k=1 to 1
+Module Biorhythms (birth, bioDay, N as long = 1) {
+ date birth, bioDay, transition
+ enum bio {Physical=23, Emotional=28, Mental=33}
+ dim quadrants(4)
+ quadrants(0):=("up and rising", "peak"), ("up but falling", "transition"), ("down and falling", "valley"), ("down but rising", "transition")
+ if N<1 then N=1
+ for k=1 to N
long Days=bioDay-birth
- Print "Day "+(bioDay)+":"
-
+ Print "Day "+bioDay+" | Age in days: "+Days
string frm="{0:-20} : {1}", pword, dfmt="YYYY-MM-DD"
- long position, percentage, length, targetday
+ long position, percentage, length
k=each(bio)
while k
- length=eval(k)
-
+ length=eval(k)
position=days mod length
quadrant=int(4*position/length)
- targetday=bioDay // get the long value of day from date type
percentage=100*sin(360*position/length)
- transition=bioDay+floor((quadrant+1)/4*23)-position
+ transition=bioDay+floor((quadrant+1)/4*length)-position
select case percentage
case >95
pword="peak"
@@ -27,14 +24,15 @@ Module Biorhythms {
case -5 to 5
pword="critical "
case else
- {
- pword=percentage+"% ("+quadrants#val(quadrant)#val$(0)+", next "
- pword+=quadrants#val(quadrant)#val$(1)+" "+str$(transition,dfmt)+")"
- }
+ {
+ pword=percentage+"% ("+quadrants(quadrant)#val$(0)+", next "
+ pword+=quadrants(quadrant)#val$(1)+" "+str$(transition, dfmt)+")"
+ }
end select
print format$(frm, eval$(k)+" day "+(days mod length), pword)
End while
bioDay++
next k
}
-Biorhythms
+form 80
+Biorhythms "1943-03-09", "1972-07-11"
diff --git a/Task/Biorhythms/Scala/biorhythms.scala b/Task/Biorhythms/Scala/biorhythms-1.scala
similarity index 100%
rename from Task/Biorhythms/Scala/biorhythms.scala
rename to Task/Biorhythms/Scala/biorhythms-1.scala
diff --git a/Task/Biorhythms/Scala/biorhythms-2.scala b/Task/Biorhythms/Scala/biorhythms-2.scala
new file mode 100644
index 0000000000..347b8ef0ba
--- /dev/null
+++ b/Task/Biorhythms/Scala/biorhythms-2.scala
@@ -0,0 +1,94 @@
+import java.time.LocalDate
+import java.time.format.DateTimeFormatter
+import java.time.temporal.ChronoUnit
+import scala.jdk.CollectionConverters._
+
+object Biorhythms extends App {
+
+ private val datePairs = List(
+ ("1943-03-09", "1972-07-11"),
+ ("1809-01-12", "1863-11-19"),
+ ("1809-02-12", "1863-11-19")
+ )
+
+ datePairs.foreach(calculateBiorhythms)
+
+ private def calculateBiorhythms(dates: (String, String)): Unit = {
+ val formatter = DateTimeFormatter.ISO_LOCAL_DATE
+ val birthDate = LocalDate.parse(dates._1, formatter)
+ val targetDate = LocalDate.parse(dates._2, formatter)
+ val daysBetween = ChronoUnit.DAYS.between(birthDate, targetDate).toInt
+
+ println(s"Birth Date: $birthDate, Target Date: $targetDate")
+ println(s"Days Between: $daysBetween")
+
+ Cycle.values.foreach(processCycle(daysBetween, targetDate, _))
+
+ println()
+ }
+
+ private def processCycle(daysBetween: Int, targetDate: LocalDate, cycle: Cycle): Unit = {
+ val position = daysBetween % cycle.length
+ val angle = 2 * Math.PI * position / cycle.length
+ val percentage = Math.round(100 * Math.sin(angle)).toInt
+
+ val description = percentage match {
+ case p if p > 95 => "peak"
+ case p if p < -95 => "valley"
+ case p if Math.abs(p) < 5 => "critical transition"
+ case _ =>
+ val quadrant = Quadrant.fromPosition(position, cycle.length)
+ val daysToTransition = quadrant.daysToTransition(position, cycle.length)
+ val transitionDate = targetDate.plusDays(daysToTransition)
+ val (trend, nextTransition) = quadrant.getDescriptions
+ s"$percentage% ($trend, $nextTransition on $transitionDate)"
+ }
+
+ println(s"${cycle} day $position: $description")
+ }
+
+ private enum Cycle(val length: Int) {
+ private case PHYSICAL extends Cycle(23)
+ private case EMOTIONAL extends Cycle(28)
+ private case MENTAL extends Cycle(33)
+
+ override def toString: String = this match {
+ case PHYSICAL => "Physical"
+ case EMOTIONAL => "Emotional"
+ case MENTAL => "Mental"
+ }
+ }
+
+ enum Quadrant {
+ case UpAndRising
+ case UpButFalling
+ case DownAndFalling
+ case DownButRising
+
+ def getDescriptions: (String, String) = this match {
+ case UpAndRising => ("up and rising", "next peak")
+ case UpButFalling => ("up but falling", "next transition")
+ case DownAndFalling => ("down and falling", "next valley")
+ case DownButRising => ("down but rising", "next transition")
+ }
+
+ def daysToTransition(position: Int, cycleLength: Int): Int = {
+ val quarter = cycleLength / 4
+ val positionInQuadrant = position % quarter
+ quarter - positionInQuadrant
+ }
+ }
+
+ private object Quadrant {
+ def fromPosition(position: Int, cycleLength: Int): Quadrant = {
+ val relativePosition = position.toDouble / cycleLength
+ relativePosition match {
+ case p if p >= 0.0 && p < 0.25 => Quadrant.UpAndRising
+ case p if p >= 0.25 && p < 0.5 => Quadrant.UpButFalling
+ case p if p >= 0.5 && p < 0.75 => Quadrant.DownAndFalling
+ case p if p >= 0.75 && p < 1.0 => Quadrant.DownButRising
+ case _ => throw new IllegalArgumentException("Position out of bounds")
+ }
+ }
+ }
+}
diff --git a/Task/Bitmap-B-zier-curves-Cubic/ALGOL-68/bitmap-b-zier-curves-cubic-2.alg b/Task/Bitmap-B-zier-curves-Cubic/ALGOL-68/bitmap-b-zier-curves-cubic-2.alg
index e19cad1f9b..64efe22d15 100644
--- a/Task/Bitmap-B-zier-curves-Cubic/ALGOL-68/bitmap-b-zier-curves-cubic-2.alg
+++ b/Task/Bitmap-B-zier-curves-Cubic/ALGOL-68/bitmap-b-zier-curves-cubic-2.alg
@@ -1,12 +1,12 @@
#!/usr/bin/a68g --script #
# -*- coding: utf-8 -*- #
-PR READ "prelude/Bitmap.a68" PR; # c.f. [[rc:Bitmap]] #
-PR READ "prelude/Bitmap/Bresenhams_line_algorithm.a68" PR; # c.f. [[rc:Bitmap/Bresenhams_line_algorithm]] #
+PR READ "prelude/Bitmap.a68" PR;
+PR READ "prelude/Bitmap/Bresenhams_line_algorithm.a68" PR;
PR READ "prelude/Bitmap/Bezier_curves/Cubic.a68" PR;
-# The following test #
-test:(
+### test program ###
+(
REF IMAGE x = INIT LOC[16,16]PIXEL;
(fill OF class image)(x, (white OF class image));
(cubic bezier OF class image)(x, (16, 1), (1, 4), (3, 16), (15, 11), (black OF class image), EMPTY);
diff --git a/Task/Bitmap-B-zier-curves-Quadratic/ALGOL-68/bitmap-b-zier-curves-quadratic.alg b/Task/Bitmap-B-zier-curves-Quadratic/ALGOL-68/bitmap-b-zier-curves-quadratic.alg
new file mode 100644
index 0000000000..c06ba96d7a
--- /dev/null
+++ b/Task/Bitmap-B-zier-curves-Quadratic/ALGOL-68/bitmap-b-zier-curves-quadratic.alg
@@ -0,0 +1,41 @@
+BEGIN # draw a quadratic curve using Bresenham's line algoritm #
+
+ PR READ "prelude/Bitmap.a68" PR;
+ PR READ "prelude/Bitmap/Bresenhams_line_algorithm.a68" PR;
+
+ PROC quadratic bezier = ( REF IMAGE bm, INT x1, y1, x2, y2, x3, y3, nseg, REAL scale )VOID:
+ BEGIN
+ INT prevx := 0, prevy := 0;
+ FOR i FROM 0 TO nseg DO
+ REAL t = i / nseg;
+ REAL t1 = 1 - t;
+ REAL a = t1 * t1;
+ REAL b = 2 * t * t1;
+ REAL c = t * t;
+ INT currx = ENTIER ( scale * ( a * x1 + b * x2 + c * x3 + 0.5 ) );
+ INT curry = ENTIER ( scale * ( a * y1 + b * y2 + c * y3 + 0.5 ) );
+ IF i > 0 THEN
+ ( line OF class image )( bm
+ , ( prevx, prevy )
+ , ( currx, curry )
+ , black OF class image
+ )
+ FI;
+ prevx := currx;
+ prevy := curry
+ OD
+ END # quadratic bezier # ;
+
+ BEGIN
+ REF IMAGE bm = INIT LOC[ 1 : 60, 1 : 40 ]PIXEL;
+ ( fill OF class image )( bm, white OF class image );
+ quadratic bezier( bm, 10, 100, 250, 270, 150, 20, 20, 70 / 300 );
+ # print in monochrome #
+ FOR y FROM 2 UPB bm BY -1 TO 2 LWB bm DO
+ FOR x FROM 1 LWB bm TO 1 UPB bm DO
+ print( ( IF PIXEL( bm[ x, y ] ) /= white OF class image THEN "##" ELSE " " FI ) )
+ OD;
+ print( ( newline ) )
+ OD
+ END
+END
diff --git a/Task/Bitmap-B-zier-curves-Quadratic/EasyLang/bitmap-b-zier-curves-quadratic.easy b/Task/Bitmap-B-zier-curves-Quadratic/EasyLang/bitmap-b-zier-curves-quadratic.easy
new file mode 100644
index 0000000000..2edb8d1510
--- /dev/null
+++ b/Task/Bitmap-B-zier-curves-Quadratic/EasyLang/bitmap-b-zier-curves-quadratic.easy
@@ -0,0 +1,19 @@
+proc quadraticbezier x1 y1 x2 y2 x3 y3 nseg . .
+ for i = 0 to nseg
+ t = i / nseg
+ t1 = 1 - t
+ a = t1 * t1
+ b = 2 * t * t1
+ c = t * t
+ currx = a * x1 + b * x2 + c * x3 + 0.5
+ curry = a * y1 + b * y2 + c * y3 + 0.5
+ if i = 0
+ move currx curry
+ else
+ line currx curry
+ .
+ .
+.
+linewidth 0.5
+clear
+quadraticbezier 1 1 30 37 59 1 100
diff --git a/Task/Bitmap-B-zier-curves-Quadratic/M2000-Interpreter/bitmap-b-zier-curves-quadratic.m2000 b/Task/Bitmap-B-zier-curves-Quadratic/M2000-Interpreter/bitmap-b-zier-curves-quadratic.m2000
new file mode 100644
index 0000000000..a5b02611cc
--- /dev/null
+++ b/Task/Bitmap-B-zier-curves-Quadratic/M2000-Interpreter/bitmap-b-zier-curves-quadratic.m2000
@@ -0,0 +1,191 @@
+module bezier {
+ Function Bitmap {
+ def x as long, y as long, Import as boolean
+ If match("NN") then
+ Read x, y
+ else.if Match("N") Then
+ \\ is a file?
+ Read f as long
+ byte whitespace[0]
+ if not Eof(f) then
+ get #f, whitespace :P6$=chr$(whitespace[0])
+ get #f, whitespace : P6$+=chr$(whitespace[0])
+ boolean getW=true, getH=true, getV=true
+ long v
+ If p6$="P6" Then
+ do
+ get #f, whitespace
+ select case whitespace[0]
+ case 35
+ {do get #f, whitespace
+ until whitespace[0]=10
+ }
+ case 32, 9, 13, 10
+ { if getW and x<>0 then
+ getW=false
+ else.if getH and y<>0 then
+ getH=false
+ else.if getV and v<>0 then
+ getV=false
+ end if
+ }
+ case 48 to 57
+ {if getW then
+ x*=10
+ x+=whitespace[0]-48
+ else.if getH then
+ y*=10
+ y+=whitespace[0]-48
+ else.if getV then
+ v*=10
+ v+=whitespace[0]-48
+ end if
+ }
+ End Select
+ iF eof(f) then Error "Not a ppm file"
+ until getV=false
+ else
+ Error "Not a P6 ppm"
+ end if
+ Import=True
+ end if
+ else
+ Error "No proper arguments"
+ end if
+ if x<1 or y<1 then Error "Wrong dimensions"
+ structure rgb {
+ red as byte
+ green as byte
+ blue as byte
+ }
+ m=len(rgb)*x mod 4
+ if m>0 then m=4-m ' add some bytes to raster line
+ m+=len(rgb) *x
+ Structure rasterline {
+ {
+ pad as byte*m
+ }
+ hline as rgb*x
+ }
+ Structure Raster {
+ magic as integer*4
+ w as integer*4
+ h as integer*4
+ {
+ linesB as byte*len(rasterline)*y
+ }
+ lines as rasterline*y
+ }
+ Buffer Clear Image1 as Raster
+ Return Image1, 0!magic:="cDIB", 0!w:=Hex$(x,2), 0!h:=Hex$(y, 2)
+ if not Import then Return Image1, 0!lines:=String$(chrcode$(0xffff), Len(rasterline)*y div 2)
+ Buffer Clear Pad as Byte*4
+ SetPixel=Lambda Image1, Pad, aLines=Len(Raster)-Len(Rasterline), blines=-Len(Rasterline) (x, y, c) ->{
+ where=alines+3*x+blines*y
+ if c>0 then c=color(c)
+ c-!
+ Return Pad, 0:=c as long
+ Return Image1, 0!where:=Eval(Pad, 2) as byte, 0!where+1:=Eval(Pad, 1) as byte, 0!where+2:=Eval(Pad, 0) as byte
+ }
+ GetPixel=Lambda Image1,aLines=Len(Raster)-Len(Rasterline), blines=-Len(Rasterline) (x,y) ->{
+ where=alines+3*x+blines*y
+ =color(Eval(image1, where+2 as byte), Eval(image1, where+1 as byte), Eval(image1, where as byte))
+ }
+ StrDib$=Lambda$ Image1, Raster -> {
+ =Eval$(Image1, 0, Len(Raster))
+ }
+ CopyImage=Lambda Image1 (image$) -> {
+ if left$(image$,12)=Eval$(Image1, 0, 24 ) Then {
+ Return Image1, 0:=Image$
+ } Else Error "Can't Copy Image"
+ }
+ Export2File=Lambda Image1, x, y (f) -> {
+ Print #f, "P6";chr$(10);"# Created using M2000 Interpreter";chr$(10);
+ Print #f, x;" ";y;" 255";chr$(10);
+ x2=x-1 : where=0
+ x0=x*3
+ structure rgbP6 {
+ r as byte
+ g as byte
+ b as byte
+ }
+ buffer Pad as rgbP6*x*y
+ For y1=y-1 to 0 {
+ Return pad, x*y1:=eval$(image1, 0!linesB!where, x0)
+ where+=x0
+ m=where mod 4 : if m<>0 then where+=4-m
+ }
+ For x1=0 to x*y-1 {
+ Push Eval(pad, x1!b) : Return pad, x1!b:=Eval(pad, x1!r), x1!r:=Number
+ }
+ Put #f, pad
+ }
+ if Import then {
+ x0=x-1 : where=0
+ structure rgbP6 {
+ r as byte, g as byte, b as byte
+ }
+ buffer Pad1 as rgbP6*x*y
+ Get #f, Pad1
+ For x1=0 to x*y-1 {
+ Push Eval(pad1, x1!b) : Return pad1, x1!b:=Eval(pad1, x1!r), x1!r:=Number
+ }
+ x1=x*3
+ For y1=y-1 to 0 {
+ Return Image1, 0!linesB!where:=Eval$(Pad1, y1*x, x1)
+ where+=3*(x0+1)
+ m=where mod 4 : if m<>0 then where+=4-m
+ }
+ }
+ Group Bitmap {
+ type:Bitmap
+ SetPixel=SetPixel
+ GetPixel=GetPixel
+ Image$=StrDib$
+ Copy=CopyImage
+ ToFile=Export2File
+ }
+ =Bitmap
+ }
+ module bezier (&ppm as Bitmap, x1, y1, x2, y2, x3, y3, n, col=0){
+ Group point_ {
+ long x,y
+ }
+ Long i
+ Double t, t1, a, b, c, d
+ Dim p(n+1)=point_
+ For i = 0 To n
+ t = i / n
+ t1 = 1 - t
+ a = t1 ^ 2
+ b = t * t1 * 2
+ c = t ^ 2
+ p(i).x = Int(a * x1 + b * x2 + c * x3 + .5)
+ p(i).y = Int(a * y1 + b * y2 + c * y3 + .5)
+ Next
+
+ For i = 0 To n -1
+ Br_line(p(i).x, p(i).y, p(i +1).x, p(i +1).y, col)
+ Next
+ sub Br_line(x0 As Long, y0 As Long, x1 As Long, y1 As Long, Col=0)
+ Local Long dx = Abs(x1 - x0), dy = Abs(y1 - y0)
+ Local Long sx = If(x0 < x1-> 1, -1)
+ Local Long sy = If(y0 < y1-> 1, -1)
+ Local Long er = If(dx > dy-> dx, -dy) div 2, e2
+ Do
+ Call ppm.SetPixel(x0, y0, Col)
+ If x0=x1 And y0=y1 Then Exit
+ e2 = er
+ If e2 > -dx Then Er -= dy : x0 += sx
+ If e2 < dy Then Er += dx : y0 += sy
+ Always
+ end sub
+ }
+ A=Bitmap(250, 250)
+ bezier &A, 10, 100, 220, 310, 150, 20, 20
+ move 3000,3000 : image A.Image$()
+ Open "curve.ppm" for output as #f
+ Call A.tofile(f)
+ close #f
+}
+bezier
diff --git a/Task/Bitmap-Bresenhams-line-algorithm/ALGOL-68/bitmap-bresenhams-line-algorithm-1.alg b/Task/Bitmap-Bresenhams-line-algorithm/ALGOL-68/bitmap-bresenhams-line-algorithm-1.alg
deleted file mode 100644
index 71ca3c026d..0000000000
--- a/Task/Bitmap-Bresenhams-line-algorithm/ALGOL-68/bitmap-bresenhams-line-algorithm-1.alg
+++ /dev/null
@@ -1,42 +0,0 @@
-# -*- coding: utf-8 -*- #
-
-line OF class image := (REF IMAGE picture, POINT start, stop, PIXEL color)VOID:
-BEGIN
- REAL dx = ABS (x OF stop - x OF start),
- dy = ABS (y OF stop - y OF start);
- REAL err;
- POINT here := start,
- step := (1, 1);
- IF x OF start > x OF stop THEN
- x OF step := -1
- FI;
- IF y OF start > y OF stop THEN
- y OF step := -1
- FI;
- IF dx > dy THEN
- err := dx / 2;
- WHILE x OF here /= x OF stop DO
- picture[x OF here, y OF here] := color;
- err -:= dy;
- IF err < 0 THEN
- y OF here +:= y OF step;
- err +:= dx
- FI;
- x OF here +:= x OF step
- OD
- ELSE
- err := dy / 2;
- WHILE y OF here /= y OF stop DO
- picture[x OF here, y OF here] := color;
- err -:= dx;
- IF err < 0 THEN
- x OF here +:= x OF step;
- err +:= dy
- FI;
- y OF here +:= y OF step
- OD
- FI;
- picture[x OF here, y OF here] := color # ensure dots to be drawn #
-END # line #;
-
-SKIP
diff --git a/Task/Bitmap-Bresenhams-line-algorithm/ALGOL-68/bitmap-bresenhams-line-algorithm-2.alg b/Task/Bitmap-Bresenhams-line-algorithm/ALGOL-68/bitmap-bresenhams-line-algorithm.alg
similarity index 89%
rename from Task/Bitmap-Bresenhams-line-algorithm/ALGOL-68/bitmap-bresenhams-line-algorithm-2.alg
rename to Task/Bitmap-Bresenhams-line-algorithm/ALGOL-68/bitmap-bresenhams-line-algorithm.alg
index d1ba6015a9..223c635fd0 100644
--- a/Task/Bitmap-Bresenhams-line-algorithm/ALGOL-68/bitmap-bresenhams-line-algorithm-2.alg
+++ b/Task/Bitmap-Bresenhams-line-algorithm/ALGOL-68/bitmap-bresenhams-line-algorithm.alg
@@ -1,11 +1,11 @@
#!/usr/bin/a68g --script #
# -*- coding: utf-8 -*- #
-PR READ "prelude/Bitmap.a68" PR; # c.f. [[rc:Bitmap]] #
+PR READ "prelude/Bitmap.a68" PR;
PR READ "prelude/Bitmap/Bresenhams_line_algorithm.a68" PR;
### The test program: ###
-test:(
+(
REF IMAGE x = INIT LOC[1:16, 1:16]PIXEL;
(fill OF class image)(x, white OF class image);
(line OF class image)(x, ( 1, 8), ( 8,16), black OF class image);
diff --git a/Task/Bitmap-Bresenhams-line-algorithm/Arturo/bitmap-bresenhams-line-algorithm.arturo b/Task/Bitmap-Bresenhams-line-algorithm/Arturo/bitmap-bresenhams-line-algorithm.arturo
new file mode 100644
index 0000000000..874b30a87e
--- /dev/null
+++ b/Task/Bitmap-Bresenhams-line-algorithm/Arturo/bitmap-bresenhams-line-algorithm.arturo
@@ -0,0 +1,67 @@
+; Bitmap object definition
+define :bitmap [
+ init: method [width :integer height :integer][
+ \width: width
+ \height: height
+ \grid: array.of:@[width height] false
+ ]
+
+ setOn: method [x :integer y :integer][
+ \grid\[y]\[x]: true
+ ]
+
+ line: method [x0 :integer y0 :integer x1 :integer y1 :integer][
+ [dx,dy]: @[abs x1 - x0, abs y1 - y0]
+ [x,y]: @[x0, y0]
+ sx: (x0 > x1) ? -> neg 1 -> 1
+ sy: (y0 > y1) ? -> neg 1 -> 1
+
+ switch dx > dy [
+ err: dx // 2
+ while [x <> x1][
+ \setOn x y
+ if negative? err: <= err - dy ->
+ [y, err]: @[y + sy, err + dx]
+
+ x: x + sx
+ ]
+ ][
+ err: dy // 2
+ while [y <> y1][
+ \setOn x y
+ if negative? err: <= err - dx ->
+ [x, err]: @[x + sx, err + dy]
+ y: y + sy
+ ]
+ ]
+ \setOn x y
+ ]
+
+ string: method [][
+ join.with:"\n" @[
+ "+" ++ (repeat "-" \width) ++ "+"
+ join.with:"\n" map 0..dec \height 'y [
+ "|" ++ (join.with:"" map 0..dec \width 'x ->
+ \grid\[dec \height-y]\[x] ? -> "@" -> " "
+ ) ++ "|"
+ ]
+ "+" ++ (repeat "-" \width) ++ "+"
+ ]
+ ]
+]
+
+; Create bitmap
+bitmap: to :bitmap @[17 17]!
+
+; and... draw a diamond shape
+points: @[
+ [1 8 8 16]
+ [8 16 16 8]
+ [16 8 8 1]
+ [8 1 1 8]
+]
+
+loop points 'p ->
+ bitmap\line p\0 p\1 p\2 p\3
+
+print bitmap
diff --git a/Task/Bitmap-Bresenhams-line-algorithm/M2000-Interpreter/bitmap-bresenhams-line-algorithm.m2000 b/Task/Bitmap-Bresenhams-line-algorithm/M2000-Interpreter/bitmap-bresenhams-line-algorithm.m2000
new file mode 100644
index 0000000000..5ed0c0f987
--- /dev/null
+++ b/Task/Bitmap-Bresenhams-line-algorithm/M2000-Interpreter/bitmap-bresenhams-line-algorithm.m2000
@@ -0,0 +1,20 @@
+' using Twips
+' twipsX is 15 twips. So for 96 dpi, we have 1440/96=15 twips/pixel
+Module Bresenham_s_line_algorithm {
+ Module Br_line(x0 As Long, y0 As Long, x1 As Long, y1 As Long, Col=15) {
+ Long dx = Abs(x1 - x0), dy = Abs(y1 - y0)
+ Long sx = If(x0 < x1-> TWIPSX, -TWIPSX)
+ Long sy = If(y0 < y1-> TWIPSY, -TWIPSY)
+ Long er = If(dx > dy-> dx, -dy) div 2, e2
+ Do
+ PSet col, x0, y0
+ If abs(x0-x1)<=TWIPSX And abs(y0-y1)<=TWIPSY Then Exit
+ e2 = er
+ If e2 > -dx Then Er -= dy : x0 += sx
+ If e2 < dy Then Er += dx : y0 += sy
+ Always
+ }
+ cls ,0
+ Br_line scale.x*.2, scale.y*.2, scale.x*.8, scale.y*.8 , #FFbb77
+}
+Bresenham_s_line_algorithm
diff --git a/Task/Bitmap-Midpoint-circle-algorithm/ALGOL-68/bitmap-midpoint-circle-algorithm-2.alg b/Task/Bitmap-Midpoint-circle-algorithm/ALGOL-68/bitmap-midpoint-circle-algorithm-2.alg
index e3b8b12235..f48de65ee9 100644
--- a/Task/Bitmap-Midpoint-circle-algorithm/ALGOL-68/bitmap-midpoint-circle-algorithm-2.alg
+++ b/Task/Bitmap-Midpoint-circle-algorithm/ALGOL-68/bitmap-midpoint-circle-algorithm-2.alg
@@ -1,13 +1,12 @@
#!/usr/bin/a68g --script #
# -*- coding: utf-8 -*- #
-PR READ "prelude/Bitmap.a68" PR; # c.f. [[rc:Bitmap]] #
-PR READ "prelude/Bitmap/Bresenhams_line_algorithm.a68" PR; # c.f. [[rc:Bitmap/Bresenhams_line_algorithm]] #
+PR READ "prelude/Bitmap.a68" PR;
+PR READ "prelude/Bitmap/Bresenhams_line_algorithm.a68" PR;
PR READ "prelude/Bitmap/Midpoint_circle_algorithm.a68" PR;
# The following illustrates use: #
-
-test:(
+(
REF IMAGE x = INIT LOC [1:16, 1:16] PIXEL;
(fill OF class image)(x, (white OF class image));
(circle OF class image)(x, (8, 8), 5, (black OF class image));
diff --git a/Task/Bitmap-PPM-conversion-through-a-pipe/FreeBASIC/bitmap-ppm-conversion-through-a-pipe.basic b/Task/Bitmap-PPM-conversion-through-a-pipe/FreeBASIC/bitmap-ppm-conversion-through-a-pipe.basic
new file mode 100644
index 0000000000..5633823dd7
--- /dev/null
+++ b/Task/Bitmap-PPM-conversion-through-a-pipe/FreeBASIC/bitmap-ppm-conversion-through-a-pipe.basic
@@ -0,0 +1,64 @@
+Const ancho = 400
+Const alto = 300
+Dim As Integer i, x, y
+Dim As Ulong kolor
+
+' Set up graphics
+Screenres ancho, alto, 32
+Windowtitle "Pattern Generator"
+
+' A little extravagant, this draws a design of dots and lines
+' Fill background with color Rgb(&h40, &h80, &hc0)
+Line (0, 0)-(ancho-1, alto-1), Rgb(64, 128, 192), BF
+
+' Draw random dots Rgb(&h20, &h40, &h80)
+For i = 1 To 2000
+ Pset (Rnd * (ancho-1), Rnd * (alto-1)), Rgb(32, 64, 128)
+Next
+
+' Draw horizontal lines
+For x = 0 To ancho-1
+ For y = 240 To 244
+ Pset (x, y), Rgb(32, 64, 128)
+ Next
+ For y = 260 To 264
+ Pset (x, y), Rgb(32, 64, 128)
+ Next
+Next
+
+' Draw vertical lines
+For y = 0 To alto-1
+ For x = 80 To 84
+ Pset (x, y), Rgb(32, 64, 128)
+ Next
+ For x = 95 To 99
+ Pset (x, y), Rgb(32, 64, 128)
+ Next
+Next
+
+' Open PPM file to write
+Dim As Integer ff = Freefile
+Open "noutput.ppm" For Binary As #ff
+If Err > 0 Then Print "Error opening output file": End
+
+' Write PPM header
+Put #ff, , "P6" & Chr(10)
+Put #ff, , Str(ancho) & " " & Str(alto) & Chr(10)
+Put #ff, , "255" & Chr(10)
+
+' Write pixel data
+For y = 0 To alto - 1
+ For x = 0 To ancho - 1
+ kolor = Point(x, y)
+ Put #ff, , Cbyte(kolor Shr 16) ' Blue
+ Put #ff, , Cbyte(kolor Shr 8) ' Green
+ Put #ff, , Cbyte(kolor) ' Red
+ Next
+Next
+
+Close #ff
+
+' Convert to JPG using ImageMagick (pipe logic)
+Shell "magick.exe noutput.ppm noutput.jpg"
+
+Sleep
diff --git a/Task/Bitmap-Read-an-image-through-a-pipe/FreeBASIC/bitmap-read-an-image-through-a-pipe.basic b/Task/Bitmap-Read-an-image-through-a-pipe/FreeBASIC/bitmap-read-an-image-through-a-pipe.basic
new file mode 100644
index 0000000000..532b629312
--- /dev/null
+++ b/Task/Bitmap-Read-an-image-through-a-pipe/FreeBASIC/bitmap-read-an-image-through-a-pipe.basic
@@ -0,0 +1,65 @@
+Type IMAGE
+ w As Integer
+ h As Integer
+ bpp As Integer
+ dato(Any) As Ubyte
+End Type
+
+Function readImageFile(filename As String, img As IMAGE) As Boolean
+ ' First convert image to PPM using temp file
+ Dim As String cmd = "magick.exe " & filename & " temp.ppm"
+ Shell(cmd)
+
+ Dim As Integer ff = Freefile
+ Open "temp.ppm" For Binary As #ff
+
+ ' Read PPM header
+ Dim As String linea
+ Line Input #ff, linea ' P6
+ If Left(linea, 2) <> "P6" Then Return True
+
+ ' Skip comments
+ Do
+ Line Input #ff, linea
+ If Left(linea, 1) <> "#" Then Exit Do
+ Loop
+
+ img.w = Val(Left(linea, Instr(linea, " ")))
+ img.h = Val(Mid(linea, Instr(linea, " ")))
+
+ ' Allocate memory for image data
+ Redim img.dato(img.w * img.h * 3 - 1)
+
+ ' Read binary pixel data
+ Get #ff, , img.dato()
+
+ Close #ff
+ Kill("temp.ppm") ' Clean up temp file
+ Return False
+End Function
+
+Function writePPM(filename As String, img As IMAGE) As Boolean
+ Dim As Integer ff = Freefile
+ Open filename For Binary As #ff
+
+ ' Write PPM header
+ Put #ff, , "P6" & Chr(10)
+ Put #ff, , Str(img.w) & " " & Str(img.h) & Chr(10)
+ Put #ff, , "255" & Chr(10)
+
+ ' Write image data
+ For i As Integer = 0 To (img.w * img.h * 3 - 1) Step 3
+ Put #ff, , img.dato(i + 1) ' Green
+ Put #ff, , img.dato(i + 2) ' Blue
+ Put #ff, , img.dato(i) ' Red
+ Next
+
+ Close #ff
+ Return False
+End Function
+
+' Main program
+Dim As IMAGE img
+
+If readImageFile("example.png", img) Then Print "Error reading input file"
+If writePPM("output.ppm", img) Then Print "i:\Error writing PPM file"
diff --git a/Task/Bitmap-Write-a-PPM-file/FreeBASIC/bitmap-write-a-ppm-file.basic b/Task/Bitmap-Write-a-PPM-file/FreeBASIC/bitmap-write-a-ppm-file.basic
index a955daa425..d658dc3b0d 100644
--- a/Task/Bitmap-Write-a-PPM-file/FreeBASIC/bitmap-write-a-ppm-file.basic
+++ b/Task/Bitmap-Write-a-PPM-file/FreeBASIC/bitmap-write-a-ppm-file.basic
@@ -1,7 +1,8 @@
-Dim As Integer ancho = 150, alto = 200
+Dim As Integer ancho, alto
+ancho = 150: alto = 200
Dim As Integer x, y ' width, height
-Dim As Ubyte kolor
-Screenres ancho,alto,32
+Dim As Ulong kolor
+Screenres ancho, alto, 32
' Draw circles
Screenlock
@@ -10,24 +11,26 @@ Circle (75, 100), 35, Rgb(0, 255, 0),,,, F
Circle (75, 100), 20, Rgb(0, 0, 255),,,, F
Screenunlock
-' Create PPM file header
-Dim encabezado As String
-encabezado = "P6" & Chr(10) & Str(ancho) & " " & Str(alto) & Chr(10) & "255" & Chr(10)
-
' Open PPM file to write
Dim As Integer ff = Freefile
-Open "i:\example.PPM" For Binary As #ff
-Put #ff, , encabezado
+Open "example.ppm" For Binary As #ff
+If Err > 0 Then Print "Error opening output file": End
+
+' Create PPM file header
+Print #ff, "P6"
+Print #ff, "# Created using FreeBASIC"
+Print #ff, ancho & " " & alto
+Print #ff, "255"
' Write image data to PPM file
For y = 0 To alto - 1
For x = 0 To ancho - 1
kolor = Point(x, y)
- Put #ff, , Chr( kolor And &HFF) ' Red
- Put #ff, , Chr((kolor Shr 8) And &HFF) ' Green
- Put #ff, , Chr((kolor Shr 16) And &HFF) ' Blue
- Next x
-Next y
+ Put #ff, , Cbyte(kolor Shr 8) ' Green
+ Put #ff, , Cbyte(kolor) ' Blue
+ Put #ff, , Cbyte(kolor Shr 16) ' Red
+ Next
+Next
Close #ff
diff --git a/Task/Bitmap-Write-a-PPM-file/M2000-Interpreter/bitmap-write-a-ppm-file-1.m2000 b/Task/Bitmap-Write-a-PPM-file/M2000-Interpreter/bitmap-write-a-ppm-file-1.m2000
index c2892cc958..b3c4b9607b 100644
--- a/Task/Bitmap-Write-a-PPM-file/M2000-Interpreter/bitmap-write-a-ppm-file-1.m2000
+++ b/Task/Bitmap-Write-a-PPM-file/M2000-Interpreter/bitmap-write-a-ppm-file-1.m2000
@@ -50,26 +50,28 @@ Module Checkit {
Return Image1, 0:=Image$
} Else Error "Can't Copy Image"
}
- Export2File=Lambda Image1, x, y (f) -> {
+ Export2File=Lambda Image1, x, y, r=len(rasterline) (f) -> {
\\ use this between open and close
Print #f, "P3"
Print #f,"# Created using M2000 Interpreter"
Print #f, x;" ";y
Print #f, 255
x2=x-1
- where=24
- For y1= 0 to y-1 {
+ For y1= y-1 to 0 {
a$=""
- For x1=0 to x2 {
- Print #f, a$;Eval(Image1, where +2 as byte);" ";
+ where=24+r*y1
+ x1=0
+ Print #f, Eval(Image1, where +2 as byte);" ";
+ Print #f, Eval(Image1, where+1 as byte);" ";
+ Print #f, Eval(Image1, where as byte);
+ where+=3
+ For x1=1 to x2 {
+ Print #f, " ";Eval(Image1, where +2 as byte);" ";
Print #f, Eval(Image1, where+1 as byte);" ";
Print #f, Eval(Image1, where as byte);
where+=3
- a$=" "
}
Print #f
- m=where mod 4
- if m<>0 then where+=4-m
}
}
Group Bitmap {
@@ -81,31 +83,10 @@ Module Checkit {
}
=Bitmap
}
-
A=Bitmap(10, 10)
Call A.SetPixel(5,5, color(128,0,255))
Open "A2.PPM" for Output as #F
Call A.ToFile(F)
Close #f
- ' is the same as this one
- Try {
- Open "A.PPM" for Output as #F
- Print #f, "P3"
- Print #f,"# Created using M2000 Interpreter"
- Print #f, 10;" ";10
- Print #f, 255
- For y=10-1 to 0 {
- a$=""
- For x=0 to 10-1 {
- rgb=-A.GetPixel(x, y)
- Print #f, a$;Binary.And(rgb, 0xFF); " ";
- Print #f, Binary.And(Binary.Shift(rgb, -8), 0xFF); " ";
- Print #f, Binary.Shift(rgb, -16);
- a$=" "
- }
- Print #f
- }
- Close #f
- }
}
Checkit
diff --git a/Task/Bitmap-Write-a-PPM-file/M2000-Interpreter/bitmap-write-a-ppm-file-2.m2000 b/Task/Bitmap-Write-a-PPM-file/M2000-Interpreter/bitmap-write-a-ppm-file-2.m2000
index f65d2af1b7..0cc430b1ff 100644
--- a/Task/Bitmap-Write-a-PPM-file/M2000-Interpreter/bitmap-write-a-ppm-file-2.m2000
+++ b/Task/Bitmap-Write-a-PPM-file/M2000-Interpreter/bitmap-write-a-ppm-file-2.m2000
@@ -1,177 +1,180 @@
-Module PPMbinaryP6 {
- If Version<9.4 then 1000
- If Version=9.4 Then if Revision<19 then 1000
- Module Checkit {
- Function Bitmap {
- def x as long, y as long
- If match("NN") then {
- Read x, y
- } else.if Match("N") Then {
- E$="Not a ppm file"
- Read f as long
- buffer whitespace as byte
- if not Eof(f) then {
- get #f, whitespace : iF eof(f) then Error E$
- P6$=eval$(whitespace)
- get #f, whitespace : iF eof(f) then Error E$
- P6$+=eval$(whitespace)
- def boolean getW=true, getH=true, getV=true
- def long v
- \\ str$("P6") has 2 bytes. "P6" has 4 bytes
- If p6$=str$("P6") Then {
- do {
- get #f, whitespace
- if Eval$(whitespace)=str$("#") then {
- do {
- iF eof(f) then Error E$
- get #f, whitespace
- } until eval(whitespace)=10
- } else {
- select case eval(whitespace)
- case 32, 9, 13, 10
- {
- if getW and x<>0 then {
- getW=false
- } else.if getH and y<>0 then {
- getH=false
- } else.if getV and v<>0 then {
- getV=false
- }
- }
- case 48 to 57
- {
- if getW then {
- x*=10
- x+=eval(whitespace, 0)-48
- } else.if getH then {
- y*=10
- y+=eval(whitespace, 0)-48
- } else.if getV then {
- v*=10
- v+=eval(whitespace, 0)-48
- }
- }
- End Select
- }
- iF eof(f) then Error E$
- } until getV=false
- } else Error "Not a P6 ppm"
- }
- } else Error "No proper arguments"
- if x<1 or y<1 then Error "Wrong dimensions"
- structure rgb {
- red as byte
- green as byte
- blue as byte
- }
- m=len(rgb)*x mod 4
- if m>0 then m=4-m ' add some bytes to raster line
- m+=len(rgb) *x
- Structure rasterline {
- {
- pad as byte*m
- }
- \\ union pad+hline
- hline as rgb*x
- }
- \\ we use union linesB and lines
- \\ so we can address linesb as bytes
- Structure Raster {
- magic as integer*4
- w as integer*4
- h as integer*4
- {
- linesB as byte*len(rasterline)*y
- }
- lines as rasterline*y
- }
- Buffer Clear Image1 as Raster
- \\ 24 chars as header to be used from bitmap render build in functions
- Return Image1, 0!magic:="cDIB", 0!w:=Hex$(x,2), 0!h:=Hex$(y, 2)
- \\ fill white (all 255)
- \\ Str$(string) convert to ascii, so we get all characters from words width to byte width
- if not valid(f) then Return Image1, 0!lines:=Str$(String$(chrcode$(255), Len(rasterline)*y))
- Buffer Clear Pad as Byte*4
- SetPixel=Lambda Image1, Pad,aLines=Len(Raster)-Len(Rasterline), blines=-Len(Rasterline) (x, y, c) ->{
- where=alines+3*x+blines*y
- if c>0 then c=color(c)
- c-!
- Return Pad, 0:=c as long
- Return Image1, 0!where:=Eval(Pad, 2) as byte, 0!where+1:=Eval(Pad, 1) as byte, 0!where+2:=Eval(Pad, 0) as byte
- }
- GetPixel=Lambda Image1,aLines=Len(Raster)-Len(Rasterline), blines=-Len(Rasterline) (x,y) ->{
- where=alines+3*x+blines*y
- =color(Eval(image1, where+2 as byte), Eval(image1, where+1 as byte), Eval(image1, where as byte))
- }
- StrDib$=Lambda$ Image1, Raster -> {
- =Eval$(Image1, 0, Len(Raster))
- }
- CopyImage=Lambda Image1 (image$) -> {
- if left$(image$,12)=Eval$(Image1, 0, 24 ) Then {
- Return Image1, 0:=Image$
- } Else Error "Can't Copy Image"
- }
- Export2File=Lambda Image1, x, y (f) -> {
- \\ use this between open and close
- Print #f, "P6";chr$(10);
- Print #f,"# Created using M2000 Interpreter";chr$(10);
- Print #f, x;" ";y;" 255";chr$(10);
- x2=x-1
- where=0
- Buffer pad as byte*3
- For y1= 0 to y-1 {
- For x1=0 to x2 {
- \\ use linesB which is array of bytes
- Return pad, 0:=eval$(image1, 0!linesB!where, 3)
- Push Eval(pad, 2)
- Return pad, 2:=Eval(pad, 0), 0:=Number
- Put #f, pad
- where+=3
- }
- m=where mod 4
- if m<>0 then where+=4-m
- }
- }
- if valid(F) then {
- x0=x-1
- where=0
- Buffer Pad1 as byte*3
- For y1=y-1 to 0 {
- For x1=0 to x0 {
- Get #f, Pad1 ' Read binary
- \\ reverse rgb
- Push Eval(pad1, 2)
- Return pad1, 2:=Eval(pad1, 0), 0:=Number
- Return Image1, 0!linesB!where:=Eval$(Pad1)
- where+=3
+Module P6 {
+ Function Bitmap {
+ def x as long, y as long, Import as boolean
+ If match("NN") then
+ Read x, y
+ else.if Match("N") Then
+ \\ is a file?
+ Read f as long
+ byte whitespace[0]
+ if not Eof(f) then
+ get #f, whitespace :P6$=chr$(whitespace[0])
+ get #f, whitespace : P6$+=chr$(whitespace[0])
+ boolean getW=true, getH=true, getV=true
+ long v
+ If p6$="P6" Then
+ do
+ get #f, whitespace
+ select case whitespace[0]
+ case 35
+ {do get #f, whitespace
+ until whitespace[0]=10
}
- m=where mod 4
- if m<>0 then where+=4-m
- }
- }
- Group Bitmap {
- SetPixel=SetPixel
- GetPixel=GetPixel
- Image$=StrDib$
- Copy=CopyImage
- ToFile=Export2File
- }
- =Bitmap
+ case 32, 9, 13, 10
+ { if getW and x<>0 then
+ getW=false
+ else.if getH and y<>0 then
+ getH=false
+ else.if getV and v<>0 then
+ getV=false
+ end if
+ }
+ case 48 to 57
+ {if getW then
+ x*=10
+ x+=whitespace[0]-48
+ else.if getH then
+ y*=10
+ y+=whitespace[0]-48
+ else.if getV then
+ v*=10
+ v+=whitespace[0]-48
+ end if
+ }
+ End Select
+ iF eof(f) then Error "Not a ppm file"
+ until getV=false
+ else
+ Error "Not a P6 ppm"
+ end if
+ Import=True
+ end if
+ else
+ Error "No proper arguments"
+ end if
+ if x<1 or y<1 then Error "Wrong dimensions"
+ structure rgb {
+ red as byte
+ green as byte
+ blue as byte
}
- A=Bitmap(10, 10)
- Call A.SetPixel(5,5, color(128,0,255))
- Open "A.PPM" for Output as #F
- Call A.ToFile(F)
- Close #f
-
- Print "Saved"
- Open "A.PPM" for Input as #F
- C=Bitmap(f)
- Copy 400*twipsx,200*twipsy use C.Image$()
- Close #f
- }
- Checkit
- End
- 1000 Error "Need Version 9.4, Revision 19 or higher"
+ m=len(rgb)*x mod 4
+ if m>0 then m=4-m ' add some bytes to raster line
+ m+=len(rgb) *x
+ Structure rasterline {
+ {
+ pad as byte*m
+ }
+ hline as rgb*x
+ }
+ Structure Raster {
+ magic as integer*4
+ w as integer*4
+ h as integer*4
+ {
+ linesB as byte*len(rasterline)*y
+ }
+ lines as rasterline*y
+ }
+ Buffer Clear Image1 as Raster
+ Return Image1, 0!magic:="cDIB", 0!w:=Hex$(x,2), 0!h:=Hex$(y, 2)
+ if not Import then Return Image1, 0!lines:=Str$(String$(chrcode$(255), Len(rasterline)*y))
+ Buffer Clear Pad as Byte*4
+ SetPixel=Lambda Image1, Pad, aLines=Len(Raster)-Len(Rasterline), blines=-Len(Rasterline) (x, y, c) ->{
+ where=alines+3*x+blines*y
+ if c>0 then c=color(c)
+ c-!
+ Return Pad, 0:=c as long
+ Return Image1, 0!where:=Eval(Pad, 2) as byte, 0!where+1:=Eval(Pad, 1) as byte, 0!where+2:=Eval(Pad, 0) as byte
+ }
+ GetPixel=Lambda Image1,aLines=Len(Raster)-Len(Rasterline), blines=-Len(Rasterline) (x,y) ->{
+ where=alines+3*x+blines*y
+ =color(Eval(image1, where+2 as byte), Eval(image1, where+1 as byte), Eval(image1, where as byte))
+ }
+ StrDib$=Lambda$ Image1, Raster -> {
+ =Eval$(Image1, 0, Len(Raster))
+ }
+ CopyImage=Lambda Image1 (image$) -> {
+ if left$(image$,12)=Eval$(Image1, 0, 24 ) Then {
+ Return Image1, 0:=Image$
+ } Else Error "Can't Copy Image"
+ }
+ Export2File=Lambda Image1, x, y (f) -> {
+ Print #f, "P6";chr$(10);"# Created using M2000 Interpreter";chr$(10);
+ Print #f, x;" ";y;" 255";chr$(10);
+ x2=x-1 : where=0
+ x0=x*3
+ structure rgbP6 {
+ r as byte
+ g as byte
+ b as byte
+ }
+ buffer Pad as rgbP6*x*y
+ For y1=y-1 to 0 {
+ Return pad, x*y1:=eval$(image1, 0!linesB!where, x0)
+ where+=x0
+ m=where mod 4 : if m<>0 then where+=4-m
+ }
+ For x1=0 to x*y-1 {
+ Push Eval(pad, x1!b) : Return pad, x1!b:=Eval(pad, x1!r), x1!r:=Number
+ }
+ Put #f, pad
+ }
+ if Import then {
+ x0=x-1 : where=0
+ structure rgbP6 {
+ r as byte
+ g as byte
+ b as byte
+ }
+ buffer Pad1 as rgbP6*x*y
+ Get #f, Pad1
+ For x1=0 to x*y-1 {
+ Push Eval(pad1, x1!b) : Return pad1, x1!b:=Eval(pad1, x1!r), x1!r:=Number
+ }
+ x1=x*3
+ For y1=y-1 to 0 {
+ Return Image1, 0!linesB!where:=Eval$(Pad1, y1*x, x1)
+ where+=3*(x0+1)
+ m=where mod 4 : if m<>0 then where+=4-m
+ }
+ }
+ Group Bitmap {
+ SetPixel=SetPixel
+ GetPixel=GetPixel
+ Image$=StrDib$
+ Copy=CopyImage
+ ToFile=Export2File
+ }
+ =Bitmap
+ }
+ A=Bitmap(150,100)
+ For i=0 to 98 {
+ Call A.SetPixel(i, i, 0)
+ Call A.SetPixel(99, i, 0)
+ }
+ Call A.SetPixel(i,i,0)
+ Copy 200*twipsx, 100*twipsy use A.Image$()
+ Profiler
+ Open "a.ppm" for output as #F
+ Call A.tofile(f)
+ Close #f
+ Print Filelen("a.ppm")
+ Print Timecount/1000;"sec"
+ Profiler
+ exit
+ Image A.Image$() Export "a.jpg", 100 ' per cent quality
+ Print Filelen("a.jpg")
+ Image A.Image$() Export "a1.jpg", 10 ' per cent quality
+ Print Filelen("a1.jpg")
+ Image A.Image$() Export "a.bmp"
+ Print Filelen("a.bmp") ' no compression
+ Print Timecount/1000;"sec"
+ Move 5000,5000 ' twips
+ Image "a.jpg"
+ Move 5000,8000
+ Image "a1.jpg"
+ Move 8000, 5000
+ Image "a.bmp"
}
-PPMbinaryP6
+p6
diff --git a/Task/Bitmap/ALGOL-68/bitmap-1.alg b/Task/Bitmap/ALGOL-68/bitmap-1.alg
deleted file mode 100644
index 896165161a..0000000000
--- a/Task/Bitmap/ALGOL-68/bitmap-1.alg
+++ /dev/null
@@ -1,48 +0,0 @@
-# -*- coding: utf-8 -*- #
-
-MODE PIXEL = STRUCT(#SHORT# BITS red,green,blue);
-MODE POINT = STRUCT(INT x,y);
-
-MODE IMAGE = [0,0]PIXEL; # instance attributes #
-
-MODE CLASSIMAGE = STRUCT ( # class attributes #
- PIXEL black, red, green, blue, white,
- PROC (REF IMAGE)REF IMAGE init,
- PROC (REF IMAGE, PIXEL)VOID fill,
- PROC (REF IMAGE)VOID print,
-# virtual: #
- REF PROC (REF IMAGE, POINT, POINT, PIXEL)VOID line,
- REF PROC (REF IMAGE, POINT, INT, PIXEL)VOID circle,
- REF PROC (REF IMAGE, POINT, POINT, POINT, POINT, PIXEL, UNION(INT, VOID))VOID cubic bezier
-);
-
-CLASSIMAGE class image = (
- # black = # (#SHORTEN# 16r00, #SHORTEN# 16r00, #SHORTEN# 16r00),
- # red = # (#SHORTEN# 16rff, #SHORTEN# 16r00, #SHORTEN# 16r00),
- # green = # (#SHORTEN# 16r00, #SHORTEN# 16rff, #SHORTEN# 16r00),
- # blue = # (#SHORTEN# 16r00, #SHORTEN# 16r00, #SHORTEN# 16rff),
- # white = # (#SHORTEN# 16rff, #SHORTEN# 16rff, #SHORTEN# 16rff),
- # PROC init = # (REF IMAGE self)REF IMAGE:
- BEGIN
- (fill OF class image)(self, black OF class image);
- self
- END,
-
- # PROC fill = # (REF IMAGE self, PIXEL color)VOID:
- FOR x FROM 1 LWB self TO 1 UPB self DO
- FOR y FROM 2 LWB self TO 2 UPB self DO
- self[x,y] := color
- OD
- OD,
- # PROC print = # (REF IMAGE self)VOID:
- printf(($n(UPB self)(3(16r2d))l$, self)),
-# virtual: #
- # REF PROC line = # LOC PROC (REF IMAGE, POINT, POINT, PIXEL)VOID,
- # REF PROC circle = # LOC PROC (REF IMAGE, POINT, INT, PIXEL)VOID,
- # REF PROC cubic bezier = # LOC PROC (REF IMAGE, POINT, POINT, POINT, POINT, PIXEL, UNION(INT, VOID))VOID
-);
-
-OP CLASSOF = (IMAGE image)CLASSIMAGE: class image;
-OP INIT = (REF IMAGE image)REF IMAGE: (init OF (CLASSOF image))(image);
-
-SKIP
diff --git a/Task/Bitmap/ALGOL-68/bitmap-2.alg b/Task/Bitmap/ALGOL-68/bitmap.alg
similarity index 100%
rename from Task/Bitmap/ALGOL-68/bitmap-2.alg
rename to Task/Bitmap/ALGOL-68/bitmap.alg
diff --git a/Task/Bitmap/M2000-Interpreter/bitmap-1.m2000 b/Task/Bitmap/M2000-Interpreter/bitmap-1.m2000
index 905292d6cb..ebd64b552a 100644
--- a/Task/Bitmap/M2000-Interpreter/bitmap-1.m2000
+++ b/Task/Bitmap/M2000-Interpreter/bitmap-1.m2000
@@ -1,72 +1,102 @@
-\ Bitmap width in pixels, height in pixels
-\ Return a group object with some lambda as members: SetPixel, GetPixel, Image$
-\ copyimage
-\ using Copy x, y Use Image$ we can display image$ to x, y as twips
-\ we can use x*twipsx, y*twipsy for x,y as pixels
-Function Bitmap (x as long, y as long) {
- if x<1 or y<1 then Error "Wrong dimensions"
- structure rgb {
- red as byte
- green as byte
- blue as byte
- }
- m=len(rgb)*x mod 4
- if m>0 then m=4-m ' add some bytes to raster line
- m+=len(rgb) *x
- Structure rasterline {
- {
- pad as byte*m
+Module Checkit {
+ Function Bitmap (x as long, y as long) {
+ if x<1 or y<1 then Error "Wrong dimensions"
+ structure rgb {
+ red as byte
+ green as byte
+ blue as byte
+ }
+ m=len(rgb)*x mod 4
+ if m>0 then m=4-m ' add some bytes to raster line
+ m+=len(rgb) *x
+ Structure rasterline {
+ {
+ pad as byte*m
+ }
+ \\ union pad+hline
+ hline as rgb*x
}
- \\ union pad+hline
- hline as rgb*x
- }
- Structure Raster {
- magic as integer*4
- w as integer*4
- h as integer*4
- lines as rasterline*y
- }
- Buffer Clear Image1 as Raster
- \\ 24 chars as header to be used from bitmap render build in functions
- Return Image1, 0!magic:="cDIB", 0!w:=Hex$(x,2), 0!h:=Hex$(y, 2)
- \\ fill white (all 255)
- \\ Str$(string) convert to ascii, so we get all characters from words width to byte width
- Return Image1, 0!lines:=Str$(String$(chrcode$(255), Len(rasterline)*y))
- Buffer Clear Pad as Byte*4
- SetPixel=Lambda Image1, Pad,aLines=Len(Raster)-Len(Rasterline), blines=-Len(Rasterline) (x, y, c) ->{
- where=alines+3*x+blines*y
- if c>0 then c=color(c)
- c-!
- Return Pad, 0:=c as long
- Return Image1, 0!where:=Eval(Pad, 2) as byte, 0!where+1:=Eval(Pad, 1) as byte, 0!where+2:=Eval(Pad, 0) as byte
+ Structure Raster {
+ magic as integer*4
+ w as integer*4
+ h as integer*4
+ lines as rasterline*y
+ }
+ Buffer Clear Image1 as Raster
+ \\ 24 chars as header to be used from bitmap render build in functions
+ Return Image1, 0!magic:="cDIB", 0!w:=Hex$(x,2), 0!h:=Hex$(y, 2)
+ \\ fill white (all 255)
+ \\ Str$(string) convert to ascii, so we get all characters from words width to byte width
+ Return Image1, 0!lines:=Str$(String$(chrcode$(255), Len(rasterline)*y))
+ Buffer Clear Pad as Byte*4
+ SetPixel=Lambda Image1, Pad,aLines=Len(Raster)-Len(Rasterline), blines=-Len(Rasterline) (x, y, c) ->{
+ where=alines+3*x+blines*y
+ if c>0 then c=color(c)
+ c-!
+ Return Pad, 0:=c as long
+ Return Image1, 0!where:=Eval(Pad, 2) as byte, 0!where+1:=Eval(Pad, 1) as byte, 0!where+2:=Eval(Pad, 0) as byte
+ }
+ GetPixel=Lambda Image1,aLines=Len(Raster)-Len(Rasterline), blines=-Len(Rasterline) (x,y) ->{
+ where=alines+3*x+blines*y
+ =color(Eval(image1, where+2 as byte), Eval(image1, where+1 as byte), Eval(image1, where as byte))
+ }
+ StrDib$=Lambda$ Image1, Raster -> {
+ =Eval$(Image1, 0, Len(Raster))
+ }
+ CopyImage=Lambda Image1 (image$) -> {
+ if left$(image$,12)=Eval$(Image1, 0, 24 ) Then {
+ Return Image1, 0:=Image$
+ } Else Error "Can't Copy Image"
+ }
+ Export2File=Lambda Image1, x, y, r=len(rasterline) (f) -> {
+ \\ use this between open and close
+ Print #f, "P3"
+ Print #f,"# Created using M2000 Interpreter"
+ Print #f, x;" ";y
+ Print #f, 255
+ x2=x-1
+ For y1= y-1 to 0 {
+ a$=""
+ where=24+r*y1
+ x1=0
+ Print #f, Eval(Image1, where +2 as byte);" ";
+ Print #f, Eval(Image1, where+1 as byte);" ";
+ Print #f, Eval(Image1, where as byte);
+ where+=3
+ For x1=1 to x2 {
+ Print #f, " ";Eval(Image1, where +2 as byte);" ";
+ Print #f, Eval(Image1, where+1 as byte);" ";
+ Print #f, Eval(Image1, where as byte);
+ where+=3
+ }
+ Print #f
+ }
+ }
+ Group Bitmap {
+ SetPixel=SetPixel
+ GetPixel=GetPixel
+ Image$=StrDib$
+ Copy=CopyImage
+ ToFile=Export2File
+ }
+ =Bitmap
}
- GetPixel=Lambda Image1,aLines=Len(Raster)-Len(Rasterline), blines=-Len(Rasterline) (x,y) ->{
- where=alines+3*x+blines*y
- =color(Eval(image1, where+2 as byte), Eval(image1, where+1 as byte), Eval(image1, where as byte))
+ A=Bitmap(150,100)
+ For i=0 to 98 {
+ Call A.SetPixel(i, i, 5)
+ Call A.SetPixel(99, i, color(128,0,255))
}
- StrDib$=Lambda$ Image1, Raster -> {
- =Eval$(Image1, 0, Len(Raster))
- }
- CopyImage=Lambda Image1 (image$) -> {
- if left$(image$,12)=Eval$(Image1, 0, 24 ) Then {
- Return Image1, 0:=Image$
- } Else Error "Can't Copy Image"
- }
- Group Bitmap {
- SetPixel=SetPixel
- GetPixel=GetPixel
- Image$=StrDib$
- Copy=CopyImage
- }
- =Bitmap
+ Call A.SetPixel(i,i,0)
+ Call A.SetPixel(30,50, color(128,0,255))
+ Print A.GetPixel(30,50)=color(128,0,255)
+ move 3000, 3000
+ Image A.image$()
+ profiler
+ Open "A2.PPM" for Output as #F
+ Call A.ToFile(F)
+ Close #f
+ print timecount
}
-A=Bitmap(100,100)
-Call A.SetPixel(50,50, color(128,0,255))
-Print A.GetPixel(50,50)=color(128,0,255)
-\\ display image to screen at 100, 50 pixel
-copy 100*twipsx,50*twipsy use A.Image$()
-A1=Bitmap(100,100)
-Call A1.copy(A.Image$())
-copy 500*twipsx,50*twipsy use A1.Image$()
+Checkit
diff --git a/Task/Bitmap/M2000-Interpreter/bitmap-2.m2000 b/Task/Bitmap/M2000-Interpreter/bitmap-2.m2000
index 562ea41c5b..bae307643e 100644
--- a/Task/Bitmap/M2000-Interpreter/bitmap-2.m2000
+++ b/Task/Bitmap/M2000-Interpreter/bitmap-2.m2000
@@ -1,55 +1,57 @@
Module P6 {
Function Bitmap {
def x as long, y as long, Import as boolean
-
- If match("NN") then {
+ If match("NN") then
Read x, y
- } else.if Match("N") Then {
+ else.if Match("N") Then
\\ is a file?
Read f as long
- buffer whitespace as byte
- if not Eof(f) then {
- get #f, whitespace :P6$=eval$(whitespace)
- get #f, whitespace : P6$+=eval$(whitespace)
- def boolean getW=true, getH=true, getV=true
- def long v
- \\ str$("P6") has 2 bytes. "P6" has 4 bytes
- If p6$=str$("P6") Then {
- do {
+ byte whitespace[0]
+ if not Eof(f) then
+ get #f, whitespace :P6$=chr$(whitespace[0])
+ get #f, whitespace : P6$+=chr$(whitespace[0])
+ boolean getW=true, getH=true, getV=true
+ long v
+ If p6$="P6" Then
+ do
get #f, whitespace
- if Eval$(whitespace)=str$("#") then {
- do {get #f, whitespace} until eval(whitespace)=10
- } else {
- select case eval(whitespace)
- case 32, 9, 13, 10
- { if getW and x<>0 then {
- getW=false
- } else.if getH and y<>0 then {
- getH=false
- } else.if getV and v<>0 then {
- getV=false
- }
- }
- case 48 to 57
- {if getW then {
- x*=10
- x+=eval(whitespace, 0)-48
- } else.if getH then {
- y*=10
- y+=eval(whitespace, 0)-48
- } else.if getV then {
- v*=10
- v+=eval(whitespace, 0)-48
- }
- }
- End Select
+ select case whitespace[0]
+ case 35
+ {do get #f, whitespace
+ until whitespace[0]=10
}
+ case 32, 9, 13, 10
+ { if getW and x<>0 then
+ getW=false
+ else.if getH and y<>0 then
+ getH=false
+ else.if getV and v<>0 then
+ getV=false
+ end if
+ }
+ case 48 to 57
+ {if getW then
+ x*=10
+ x+=whitespace[0]-48
+ else.if getH then
+ y*=10
+ y+=whitespace[0]-48
+ else.if getV then
+ v*=10
+ v+=whitespace[0]-48
+ end if
+ }
+ End Select
iF eof(f) then Error "Not a ppm file"
- } until getV=false
- } else Error "Not a P6 ppm"
+ until getV=false
+ else
+ Error "Not a P6 ppm"
+ end if
Import=True
- }
- } else Error "No proper arguments"
+ end if
+ else
+ Error "No proper arguments"
+ end if
if x<1 or y<1 then Error "Wrong dimensions"
structure rgb {
red as byte
@@ -78,7 +80,7 @@ Module P6 {
Return Image1, 0!magic:="cDIB", 0!w:=Hex$(x,2), 0!h:=Hex$(y, 2)
if not Import then Return Image1, 0!lines:=Str$(String$(chrcode$(255), Len(rasterline)*y))
Buffer Clear Pad as Byte*4
- SetPixel=Lambda Image1, Pad,aLines=Len(Raster)-Len(Rasterline), blines=-Len(Rasterline) (x, y, c) ->{
+ SetPixel=Lambda Image1, Pad, aLines=Len(Raster)-Len(Rasterline), blines=-Len(Rasterline) (x, y, c) ->{
where=alines+3*x+blines*y
if c>0 then c=color(c)
c-!
@@ -101,23 +103,41 @@ Module P6 {
Print #f, "P6";chr$(10);"# Created using M2000 Interpreter";chr$(10);
Print #f, x;" ";y;" 255";chr$(10);
x2=x-1 : where=0
- Buffer pad as byte*3
- For y1= 0 to y-1 {
- For x1=0 to x2 {
- Return pad, 0:=eval$(image1, 0!linesB!where, 3)
- Push Eval(pad, 2) : Return pad, 2:=Eval(pad, 0), 0:=Number
- Put #f, pad : where+=3
- }
+ x0=x*3
+ structure rgbP6 {
+ r as byte
+ g as byte
+ b as byte
+ }
+ buffer Pad as rgbP6*x*y
+ For y1=y-1 to 0 {
+ Return pad, x*y1:=eval$(image1, 0!linesB!where, x0)
+ where+=x0
m=where mod 4 : if m<>0 then where+=4-m
}
+ For x1=0 to x*y-1 {
+ Push Eval(pad, x1!b) : Return pad, x1!b:=Eval(pad, x1!r), x1!r:=Number
+ }
+ Put #f, pad
}
if Import then {
- x0=x-1 : where=0
- Buffer Pad1 as byte*3
- For y1=y-1 to 0 {
- For x1=0 to x0 {Get #f, Pad1 : Push Eval(pad1, 2) : Return pad1, 2:=Eval(pad1, 0), 0:=Number
- Return Image1, 0!linesB!where:=Eval$(Pad1) : where+=3}
- m=where mod 4 : if m<>0 then where+=4-m}
+ x0=x-1 : where=0
+ structure rgbP6 {
+ r as byte
+ g as byte
+ b as byte
+ }
+ buffer Pad1 as rgbP6*x*y
+ Get #f, Pad1
+ For x1=0 to x*y-1 {
+ Push Eval(pad1, x1!b) : Return pad1, x1!b:=Eval(pad1, x1!r), x1!r:=Number
+ }
+ x1=x*3
+ For y1=y-1 to 0 {
+ Return Image1, 0!linesB!where:=Eval$(Pad1, y1*x, x1)
+ where+=3*(x0+1)
+ m=where mod 4 : if m<>0 then where+=4-m
+ }
}
Group Bitmap {
SetPixel=SetPixel
diff --git a/Task/Bitwise-IO/Seed7/bitwise-io.seed7 b/Task/Bitwise-IO/Seed7/bitwise-io.seed7
index a5764cfc78..413c230ed9 100644
--- a/Task/Bitwise-IO/Seed7/bitwise-io.seed7
+++ b/Task/Bitwise-IO/Seed7/bitwise-io.seed7
@@ -1,14 +1,7 @@
$ include "seed7_05.s7i";
include "bitdata.s7i";
- include "strifile.s7i";
-const proc: initWriteAscii (inout file: outFile, inout integer: bitPos) is func
- begin
- outFile.bufferChar := '\0;';
- bitPos := 0;
- end func;
-
-const proc: writeAscii (inout file: outFile, inout integer: bitPos, in string: ascii) is func
+const proc: writeAscii (inout msbOutBitStream: outStream, in string: ascii) is func
local
var char: ch is ' ';
begin
@@ -16,42 +9,38 @@ const proc: writeAscii (inout file: outFile, inout integer: bitPos, in string: a
if ch > '\127;' then
raise RANGE_ERROR;
else
- putBitsMsb(outFile, bitPos, ord(ch), 7);
+ putBits(outStream, ord(ch), 7);
end if;
end for;
end func;
-const proc: finishWriteAscii (inout file: outFile, inout integer: bitPos) is func
+const proc: finishWriteAscii (inout msbOutBitStream: outStream) is func
begin
- putBitsMsb(outFile, bitPos, 0, 7); # Write a terminating NUL char.
- write(outFile, chr(ord(outFile.bufferChar)));
+ putBits(outStream, 0, 7); # Write a terminating NUL char.
+ flush(outStream);
end func;
-const func string: readAscii (inout msbBitStream: aBitStream) is func
+const func string: readAscii (inout msbInBitStream: inStream) is func
result
var string: stri is "";
local
var char: ch is ' ';
begin
- while ch <> '\0;' do
- ch := chr(getBits(aBitStream, 7));
+ repeat
+ ch := chr(getBits(inStream, 7));
if ch <> '\0;' then
stri &:= ch;
end if;
- end while;
+ until ch = '\0;';
end func;
const proc: main is func
local
- var file: aFile is STD_NULL;
- var integer: bitPos is 0;
- var msbBitStream: aBitStream is msbBitStream.value;
+ var msbOutBitStream: outStream is msbOutBitStream.value;
+ var msbInBitStream: inStream is msbInBitStream.value;
begin
- aFile := openStriFile;
- initWriteAscii(aFile, bitPos);
- writeAscii(aFile, bitPos, "Hello, Rosetta Code!");
- finishWriteAscii(aFile, bitPos);
- seek(aFile, 1);
- aBitStream := openMsbBitStream(aFile);
- writeln(literal(readAscii(aBitStream)));
+ writeAscii(outStream, "Hello, Rosetta Code!");
+ finishWriteAscii(outStream);
+ inStream := openMsbInBitStream(getBytes(outStream));
+ writeln(literal(readAscii(inStream)));
end func;
diff --git a/Task/Bitwise-operations/EasyLang/bitwise-operations.easy b/Task/Bitwise-operations/EasyLang/bitwise-operations.easy
index 433a6625bb..800e7fa354 100644
--- a/Task/Bitwise-operations/EasyLang/bitwise-operations.easy
+++ b/Task/Bitwise-operations/EasyLang/bitwise-operations.easy
@@ -1,9 +1,10 @@
-# numbers are doubles, bit operations use 32 bits and are unsigned
-x = 11
-y = 2
-print bitnot x
-print bitand x y
-print bitor x y
-print bitxor x y
-print bitshift x y
-print bitshift x -y
+# numbers are doubles, bit operations are unsigned, truncate
+# the fractional part and use 53 integer bits
+a = 14
+b = 3
+print bitand a b
+print bitor a b
+print bitxor a b
+print bitshift a b
+print bitshift a -b
+print bitand a bitnot b
diff --git a/Task/Bitwise-operations/M2000-Interpreter/bitwise-operations.m2000 b/Task/Bitwise-operations/M2000-Interpreter/bitwise-operations.m2000
new file mode 100644
index 0000000000..7185314544
--- /dev/null
+++ b/Task/Bitwise-operations/M2000-Interpreter/bitwise-operations.m2000
@@ -0,0 +1,43 @@
+module binary_ops{
+ select case random(1, 6)
+ case 1
+ Double x=10, y=2
+ case 2
+ Decimal x=10, y=2
+ case 3
+ Integer x=10, y=2
+ case 4
+ Long x=10, y=2
+ case 5 ' byte from 0 to 255 (unsigned)
+ Byte x=10, y=2
+ case else
+ Long Long x=10, y=2
+ end select
+ print type$(x)
+ //x & y values from 0 to 4294967295
+ print binary.not(x)=4294967285, sint(binary.not(x))=-11
+ print binary.and(x, y)=2
+ print binary.or(x, y)=10
+ // y values -31 to 31
+ print binary.xor(x, y)=8
+ print binary.shift(x, y)=40
+ print binary.shift(x, -y)=2
+ print binary.rotate(x, y)=40
+ print binary.rotate(x, -y)=2147483650, sint(binary.rotate(x, -y))=-2147483646
+ // Binary.Neg return Unsigned from signed values: -2147483648 (0x8000_0000&) to 2147483647 (0x7FFF_FFFF&)
+ // values>2147483647 return 2147483648
+ // values <-2147483648 return 2147483647
+ // 0xFFFF_ABCD& (signed value), 0xFFFF_ABCD unsinged value same bits
+ print 0xFFFF_ABCD&=-21555, 0xFFFF_ABCD=4294945741, sint(0xFFFF_ABCD)=-21555
+ print Binary.Neg(0xFFFF_ABCD&)=21554, Binary.Not(0xFFFF_ABCD)=21554
+ print sint(Binary.Neg(0xFFFF_ABCD&)+ uint(0xFFFF_ABCD&))=sint(Binary.Neg(0))
+ // signed 0xFFFF_ABCD& has same bits as unsigned 0xFFFF_ABCD,
+ // but have different value as used in calculations
+ print Binary.Neg(0xFFFF_ABCD&)=Binary.Not(0xFFFF_ABCD), 0xFFFF_ABCD&<>0xFFFF_ABCD
+ print Binary.Neg(0x0FFF_ABCD&)=Binary.Not(0x0FFF_ABCD), 0xFFFF_ABCD&<>0xFFFF_ABCD
+ // Add (modulo 32), x unsigned and add a negate signed (converted to unsigned)
+ print binary.add(x, binary.neg(y), 1)=8 ' 10 - 2 =12
+ print binary.add(x, binary.neg(-y), 1)=12 ' 10 - - 2 = 12
+ print sint(binary.neg(x))=-11, binary.neg(x)=binary.not(x)
+}
+binary_ops
diff --git a/Task/Bitwise-operations/Nim/bitwise-operations.nim b/Task/Bitwise-operations/Nim/bitwise-operations.nim
index 6932b12574..d831e18c5f 100644
--- a/Task/Bitwise-operations/Nim/bitwise-operations.nim
+++ b/Task/Bitwise-operations/Nim/bitwise-operations.nim
@@ -1,4 +1,4 @@
-proc bitwise(a, b) =
+proc bitwise[T: SomeInteger](a, b: T) =
echo "a and b: " , a and b
echo "a or b: ", a or b
echo "a xor b: ", a xor b
diff --git a/Task/Bitwise-operations/Raku/bitwise-operations.raku b/Task/Bitwise-operations/Raku/bitwise-operations.raku
index a7596faadb..7cbeacac55 100644
--- a/Task/Bitwise-operations/Raku/bitwise-operations.raku
+++ b/Task/Bitwise-operations/Raku/bitwise-operations.raku
@@ -9,7 +9,8 @@ sub int-bits (Int $a, Int $b) {
say '';
say_bit "$a", $a;
say '';
- say_bit "2's complement $a", +^$a;
+ say_bit "1's complement (not) $a", +^$a;
+ say_bit "2's complement $a", +^$a + 1;
say_bit "$a and $b", $a +& $b;
say_bit "$a or $b", $a +| $b;
say_bit "$a xor $b", $a +^ $b;
diff --git a/Task/Blum-integer/Ada/blum-integer.ada b/Task/Blum-integer/Ada/blum-integer.ada
new file mode 100644
index 0000000000..5c8e2c59ca
--- /dev/null
+++ b/Task/Blum-integer/Ada/blum-integer.ada
@@ -0,0 +1,89 @@
+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;
+
+procedure Blum is
+
+ Inc : Constant array (1 .. 8) of Integer := (4, 2, 4, 2, 4, 6, 2, 6);
+
+ function Is_Prime (N : Integer) return Boolean is
+ D : Integer := 5;
+ begin
+ if N < 2 then return False; end if;
+ if N mod 2 = 0 then return N = 2; end if;
+ if N mod 3 = 0 then return N = 3; end if;
+
+ while D * D <= N loop
+ if N mod D = 0 then return False; end if;
+ D := D + 2;
+ if N mod D = 0 then return False; end if;
+ D := D + 4;
+ end loop;
+
+ return True;
+ end Is_Prime;
+
+ function First_Prime_Factor (N : Integer) return Integer is
+ D : Integer := 7;
+ I : Integer := 1;
+ begin
+ if N = 1 then return 1; end if;
+ if N mod 3 = 0 then return 3; end if;
+ if N mod 5 = 0 then return 5; end if;
+
+ while D * D <= N loop
+ if N mod D = 0 then
+ return D;
+ end if;
+ D := D + Inc(I);
+ I := (I mod 8) + 1;
+ end loop;
+
+ return N;
+ end First_Prime_Factor;
+
+ I, Blum_Count : Integer := 1;
+ J, P, Q : Integer;
+ Blums : Array (1 .. 50) of Integer;
+ Counts : Array (1 .. 4) of Integer := (others => 0);
+ Final_Digits : Array (1 .. 4) of Integer := (1, 3, 7, 9);
+
+begin
+ loop
+ P := First_Prime_Factor(I);
+ if P mod 4 = 3 then
+ Q := I / P;
+ if Q /= P and Q mod 4 = 3 and Is_Prime(Q) then
+ if Blum_Count < 51 then Blums(Blum_Count) := I; end if;
+ Counts(((I mod 10) / 3) + 1) := Counts(((I mod 10) / 3) + 1) + 1;
+ Blum_Count := Blum_Count + 1;
+ if Blum_Count = 51 then
+ Put("First 50 Blum Integers:"); New_Line;
+ for J in Integer range 1 .. 50 loop
+ Put(Item => Blums(J), Width => 3); Put(" ");
+ if J mod 10 = 0 then New_Line; end if;
+ end loop;
+ New_Line;
+ elsif Blum_Count = 26829 or Blum_Count mod 100000 = 1 then
+ Put("The "); Put(Item => Blum_Count, Width => 7);
+ Put("th Blum Integer is: "); Put(Item => I, Width => 9);
+ New_Line;
+ if Blum_Count = 400001 then
+ New_Line; Put("% Distribution of the First 400,000 Blum Integers:"); New_Line;
+ for J in Integer range 1 .. 4 loop
+ Put(" "); Put(Item => Float(Counts(J)) / 4000.0, Fore => 2, Aft => 3, Exp => 0);
+ Put("% end in "); Put(Item => Final_Digits(J), Width => 1);
+ New_Line;
+ end loop;
+ exit;
+ end if;
+ end if;
+ end if;
+ end if;
+ if I mod 5 = 3 then
+ I := I + 4;
+ else
+ I := I + 2;
+ end if;
+ end loop;
+end Blum;
diff --git a/Task/Blum-integer/Fortran/blum-integer.f b/Task/Blum-integer/Fortran/blum-integer.f
new file mode 100644
index 0000000000..1108cc2fbe
--- /dev/null
+++ b/Task/Blum-integer/Fortran/blum-integer.f
@@ -0,0 +1,158 @@
+program BlumInteger
+ use, intrinsic :: iso_fortran_env, only: int32, int64
+ implicit none
+
+ integer(int32), parameter :: LIMIT = 10*1000*1000
+ integer(int32), allocatable :: BlumPrimes(:)
+ integer(int32), allocatable :: BlumPrimes2(:)
+ logical :: BlumField(0:LIMIT)
+ integer(int32) :: EndDigit(0:9)
+ integer(int64) :: k
+ integer(int32) :: n, idx, j, P4n3Cnt,xx,yy
+ call system_clock(count=xx)
+ call Sieve4n_3_Primes(LIMIT, BlumPrimes2)
+! allocate(blumprimes(0:size(BlumPrimes2)-1))
+! The blumprimes2 array is allocated in the subroutine as a zero based array
+! but, the main program doesn't know that and assumes it's 1 based so we allocate
+! a zero based array then use move_alloc to correctly resize it a transfer the data
+ allocate(blumprimes(0:1))
+ call move_alloc(blumprimes2,blumprimes)
+ P4n3Cnt = size(BlumPrimes) -1
+ print *, 'There are ', CommaUint(int(P4n3Cnt, int64)), ' needed primes 4*n+3 to Limit ', CommaUint(int(LIMIT, int64))
+ P4n3Cnt = P4n3Cnt - 1
+ print *
+
+ ! Generate Blum-Integers
+ BlumField = .false.
+ do idx = 0, P4n3Cnt
+ n = BlumPrimes(idx)
+ do j = idx+1, P4n3Cnt
+ k = int(n, int64) * int(BlumPrimes(j), int64)
+ if (k > LIMIT) exit
+ BlumField(k) = .true.
+ end do
+ end do
+ call system_clock(count=yy)
+ print *, 'First 50 Blum-Integers '
+ idx = 0
+ j = 0
+ do
+ do while (idx < LIMIT .and. .not. BlumField(idx))
+ idx = idx + 1
+ end do
+ if (idx == LIMIT) exit
+ if (mod(j, 10) == 0 .and. j /= 0) print *
+ write(*, '(I5)', advance='no') idx
+ j = j + 1
+ idx = idx + 1
+ if (j >= 50) exit
+ end do
+ print '(//)'
+
+ print *, ' relative occurence of digit'
+ print *, ' n.th |BlumInteger|Digit: 1 3 7 9'
+ idx = 0
+ j = 0
+ n = 0
+ k = 26828
+ EndDigit = 0
+ do
+ do while (idx < LIMIT .and. .not. BlumField(idx))
+ idx = idx + 1
+ end do
+ if (idx == LIMIT) exit
+ ! Count last decimal digit
+ EndDigit(mod(idx, 10)) = EndDigit(mod(idx, 10)) + 1
+ j = j + 1
+ if (j == k) then
+ write(*, '(A10,A1,A11,A1)', advance='no') CommaUint(int(j, int64)), '|', CommaUint(int(idx, int64)), '|'
+ write(*, '(F7.3,A4)', advance='no') real(EndDigit(1))/j*100, '% |'
+ write(*, '(F7.3,A4)', advance='no') real(EndDigit(3))/j*100, '% |'
+ write(*, '(F7.3,A4)', advance='no') real(EndDigit(7))/j*100, '% |'
+ write(*, '(F7.3,A2)') real(EndDigit(9))/j*100, '%'
+ if (k < 100000) then
+ k = 100000
+ else
+ k = k + 100000
+ end if
+ end if
+ idx = idx + 1
+ if (j >= 400000) exit
+ end do
+ print '(/,a,f8.6,1x,a)', 'Elapsed time = ',(yy-xx)/1000.0,'seconds'
+contains
+
+ subroutine Sieve4n_3_Primes(Limit, P4n3)
+ use iso_fortran_env
+ integer(int32), intent(in) :: Limit
+ integer(int32), allocatable, intent(out) :: P4n3(:)
+ integer(kind=1), allocatable :: sieve(:)
+ integer(int32) :: BlPrCnt, idx, n, j, sieve_size
+
+ sieve_size = (Limit / 3 - 3) / 4 + 1
+ allocate(sieve(0:sieve_size-1))
+ allocate(P4n3(0:sieve_size-1))
+
+ sieve = 0
+ BlPrCnt = 0
+ idx = 0
+ do
+ if (sieve(idx) == 0) then
+ n = idx*4 + 3
+ P4n3(BlPrCnt) = n
+ BlPrCnt = BlPrCnt + 1
+ j = idx + n
+ if (j > ubound(sieve, 1)) exit
+ do while (j <= ubound(sieve, 1))
+ sieve(j) = 1
+ j = j + n
+ end do
+ end if
+ idx = idx + 1
+ if (idx > ubound(sieve, 1)) exit
+ end do
+ ! Collect the rest
+ do idx = idx, ubound(sieve, 1)
+ if (sieve(idx) == 0) then
+ P4n3(BlPrCnt) = idx*4 + 3
+ BlPrCnt = BlPrCnt + 1
+ end if
+ end do
+ P4n3 = P4n3(0:BlPrCnt-1)
+ end subroutine Sieve4n_3_Primes
+
+ function CommaUint(n) result(res)
+ integer, parameter :: sizer = 30
+ integer(int64), intent(in) :: n
+ character(:), allocatable :: res
+ character(len=sizer) :: temp
+ integer :: fromIdx, toIdx, i
+ character :: pRes(sizer)
+
+ write(temp, '(I0)') n
+ fromIdx = len_trim(temp)
+ toIdx = fromIdx - 1
+ if (toIdx < 3) then
+ res = temp(1:fromIdx)
+ return
+ end if
+ allocate(res, mold=repeat(' ',sizer))
+ toIdx = 4*(toIdx / 3) + mod(toIdx, 3) + 1
+ pRes = ' '
+
+ do i = 1, fromIdx
+ pRes(toIdx) = temp(fromIdx-i+1:fromIdx-i+1)
+ toIdx = toIdx - 1
+ if (mod(i, 3) == 0 .and. i /= fromIdx) then
+ pRes(toIdx) = ','
+ toIdx = toIdx - 1
+ end if
+ end do
+ do i = 1,sizer ! Go from character array to string
+ res(I:I) = pRes(i)
+ end do
+!
+ res = trim(adjustl(Res))
+ end function CommaUint
+
+end program BlumInteger
diff --git a/Task/Blum-integer/FreeBASIC/blum-integer.basic b/Task/Blum-integer/FreeBASIC/blum-integer.basic
index 8b1bdd7df5..4f8b7da16f 100644
--- a/Task/Blum-integer/FreeBASIC/blum-integer.basic
+++ b/Task/Blum-integer/FreeBASIC/blum-integer.basic
@@ -1,39 +1,76 @@
-Dim Shared As Uinteger Prime1
-Dim As Uinteger n = 3, c = 0, Prime2
+#include "isprime.bas"
-Function isSemiprime(n As Uinteger) As Boolean
- Dim As Uinteger d = 3, c = 0
- While d*d <= n
- While n Mod d = 0
- If c = 2 Then Return False
- n /= d
- c += 1
- Wend
- d += 2
- Wend
- Prime1 = n
- Return c = 1
+Type PrimeHelper
+ inc(7) As Integer
+ idx As Integer
+End Type
+
+Function initPrimeHelper() As PrimeHelper
+ Dim helper As PrimeHelper
+ helper.inc(0) = 4 : helper.inc(1) = 2 : helper.inc(2) = 4
+ helper.inc(3) = 2 : helper.inc(4) = 4 : helper.inc(5) = 6
+ helper.inc(6) = 2 : helper.inc(7) = 6
+ helper.idx = 0
+ Return helper
End Function
-Print "The first 50 Blum integers:"
-Do
- If isSemiprime(n) Then
- If Prime1 Mod 4 = 3 Then
- Prime2 = n / Prime1
- If (Prime2 <> Prime1) And (Prime2 Mod 4 = 3) Then
- c += 1
- If c <= 50 Then
- Print Using "####"; n;
- If c Mod 10 = 0 Then Print
- End If
- If c >= 26828 Then
- Print !"\nThe 26828th Blum integer is: " ; n
- Exit Do
+Function firstPrimeFactor(n As Integer) As Integer
+ If n = 1 Then Return 1
+ If n Mod 3 = 0 Then Return 3
+ If n Mod 5 = 0 Then Return 5
+
+ Dim helper As PrimeHelper = initPrimeHelper()
+ Dim k As Integer = 7
+
+ While k * k <= n
+ If n Mod k = 0 Then Return k
+ k += helper.inc(helper.idx)
+ helper.idx = (helper.idx + 1) Mod 8
+ Wend
+
+ Return n
+End Function
+
+Sub main()
+ Dim As Integer blum(49), counts(9)
+ Dim As Integer bc = 0, i = 1, p, q
+ Dim As Integer j
+
+ Dim As Double t0 = Timer
+ Do
+ p = firstPrimeFactor(i)
+ If p Mod 4 = 3 Then
+ q = i \ p
+ If q <> p Andalso q Mod 4 = 3 Andalso isPrime(q) Then
+ If bc < 50 Then blum(bc) = i
+ counts(i Mod 10) += 1
+ bc += 1
+
+ If bc = 50 Then
+ Print "First 50 Blum integers:"
+ For j = 0 To 49
+ Print Using "####"; blum(j);
+ If (j + 1) Mod 10 = 0 Then Print
+ Next
+ Print
+ Elseif bc = 26828 Orelse bc Mod 100000 = 0 Then
+ Print Using "The ###,###th Blum integer is: #,###,###"; bc; i
+
+ If bc = 400000 Then
+ Print !"\n% distribution of the first 400,000 Blum integers:"
+ For j = 1 To 9 Step 2
+ If j <> 5 Then Print Using " ##.###% end in #"; (counts(j)/4000); j
+ Next
+ Exit Do
+ End If
End If
End If
End If
- End If
- n += 2
-Loop
+ i += Iif(i Mod 5 = 3, 4, 2)
+ Loop
+ Print Chr(10); Timer - t0; " sec."
+End Sub
+
+main()
Sleep
diff --git a/Task/Blum-integer/Gambas/blum-integer.gambas b/Task/Blum-integer/Gambas/blum-integer.gambas
index 027cc6a610..ce94e9d661 100644
--- a/Task/Blum-integer/Gambas/blum-integer.gambas
+++ b/Task/Blum-integer/Gambas/blum-integer.gambas
@@ -1,44 +1,67 @@
-Public Prime1 As Integer
+Use "isprime.bas"
-Public Sub Main()
+Private inc As Integer[] = [4, 2, 4, 2, 4, 6, 2, 6]
- Dim n As Integer = 3, c As Integer = 0, Prime2 As Integer
+Private Function FirstPrimeFactor(n As Long) As Long
- Print "The first 50 Blum integers:"
- Do
- If isSemiprime(n) Then
- If Prime1 Mod 4 = 3 Then
- Prime2 = n / Prime1
- If (Prime2 <> Prime1) And (Prime2 Mod 4 = 3) Then
- c += 1
- If c <= 50 Then
- Print Format$(n, "####");
- If c Mod 10 = 0 Then Print
- End If
- If c >= 26828 Then
- Print "\nThe 26828th Blum integer is: "; n
- Break
- End If
- End If
- End If
- End If
- n += 2
- Loop
+ If n = 1 Then Return 1
+ If n Mod 3 = 0 Then Return 3
+ If n Mod 5 = 0 Then Return 5
+
+ Dim k As Long = 7
+ Dim i As Integer = 0
+
+ While k * k <= n
+ If n Mod k = 0 Then Return k
+ k += inc[i]
+ i = (i + 1) Mod 8
+ Wend
+
+ Return n
End
-Function isSemiprime(n As Integer) As Boolean
+Public Sub Main()
- Dim d As Integer = 3, c As Integer = 0
- While d * d <= n
- While n Mod d = 0
- If c = 2 Then Return False
- n /= d
- c += 1
- Wend
- d += 2
+ Dim blum As New Long[50]
+ Dim counts As New Collection
+
+ counts[1] = 0
+ counts[3] = 0
+ counts[7] = 0
+ counts[9] = 0
+
+ Dim bc As Long = 0, i As Long = 1
+
+ While True
+ Dim p As Long = FirstPrimeFactor(i)
+ If p Mod 4 = 3 Then
+ Dim q As Long = i \ p
+ If q <> p And q Mod 4 = 3 And IsPrime(q) Then
+ If bc < 50 Then blum[bc] = i
+ counts[i Mod 10] += 1
+ bc += 1
+
+ If bc = 50 Then
+ Print "First 50 Blum integers:"
+ For j As Integer = 0 To 49
+ Print Format(blum[j], "####"); " ";
+ If (j + 1) Mod 10 = 0 Then Print
+ Next
+ Print
+ Else If bc = 26828 Or bc Mod 100000 = 0 Then
+ Print "The "; Format(bc, " ###,###"); "th Blum integer is: "; Format(i, " #,###,###")
+ If bc = 400000 Then
+ Print Chr(10); "% distribution of the first 400,000 Blum integers:"
+ For Each j As Integer In [1, 3, 7, 9]
+ Print Format(counts[j] / 4000, " ##.###"); "% end in "; j
+ Next
+ Return
+ Endif
+ Endif
+ Endif
+ Endif
+ i += If(i Mod 5 = 3, 4, 2)
Wend
- Prime1 = n
- Return c = 1
-End Function
+End
diff --git a/Task/Blum-integer/OxygenBasic/blum-integer.basic b/Task/Blum-integer/OxygenBasic/blum-integer.basic
new file mode 100644
index 0000000000..50ba04d0a0
--- /dev/null
+++ b/Task/Blum-integer/OxygenBasic/blum-integer.basic
@@ -0,0 +1,78 @@
+#include "isprime.bas"
+uses console
+
+dim inc(7) as integer
+inc(0) = 4: inc(1) = 2: inc(2) = 4
+inc(3) = 2: inc(4) = 4: inc(5) = 6
+inc(6) = 2: inc(7) = 6
+
+function firstPrimeFactor(n as long) as long
+ if n = 1 then return 1
+ if n mod 3 = 0 then return 3
+ if n mod 5 = 0 then return 5
+
+ long k = 7
+ int idx = 0
+
+ while k * k <= n
+ if mod(n, k) = 0 then return k
+ k += inc(idx)
+ idx = mod((idx + 1), 8)
+ wend
+ return n
+end function
+
+sub main()
+ dim as long blum(49), counts(9)
+ long bc = 0, i = 1, pct, p, q
+ int j
+ string s, t
+
+ do
+ p = firstPrimeFactor(i)
+ if p mod 4 = 3 then
+ q = i \ p
+ if q <> p and q mod 4 = 3 and isPrime(q) then
+ if bc < 50 then blum(bc) = i
+ counts(i mod 10) = counts(i mod 10) + 1
+ bc += 1
+
+ if bc = 50 then
+ printl "First 50 Blum integers:"
+ for j = 0 to 49
+ s = str(blum(j))
+ while len(s) < 4: s = " " + s: wend
+ print s;
+ if mod((j + 1), 10) = 0 then printl
+ next
+ printl
+ elseif bc = 26828 or bc mod 100000 = 0 then
+ s = str(bc)
+ while len(s) < 6: s = " " + s: wend
+ t = str(i)
+ while len(t) < 7: t = " " + t: wend
+ printl "The " + s + "th Blum integer is: " + t
+ if bc = 400000 then
+ printl cr "% distribution of the first 400,000 Blum integers:"
+
+ for j = 1 to 9 step 2
+ if j <> 5 then
+ pct = counts(j)/4000
+ s = str(pct)
+ while len(s) < 5: s = " " + s: wend
+ printl s + "% end in " + str(j)
+ end if
+ next
+ end
+ end if
+ end if
+ end if
+ end if
+ if mod(i, 5) = 3 then i += 4 else i += 2
+ end do
+end sub
+
+main()
+
+printl cr "Enter ..."
+waitkey
diff --git a/Task/Blum-integer/PureBasic/blum-integer.basic b/Task/Blum-integer/PureBasic/blum-integer.basic
new file mode 100644
index 0000000000..191ab6d065
--- /dev/null
+++ b/Task/Blum-integer/PureBasic/blum-integer.basic
@@ -0,0 +1,69 @@
+XIncludeFile "isprime.pb"
+
+Structure PrimeHelper
+ inc.i[8]
+ index.i
+EndStructure
+
+Procedure.i firstPrimeFactor(n.q)
+ If n = 1 : ProcedureReturn 1 : EndIf
+ If n % 3 = 0 : ProcedureReturn 3 : EndIf
+ If n % 5 = 0 : ProcedureReturn 5 : EndIf
+
+ Define helper.PrimeHelper
+ helper\inc[0] = 4 : helper\inc[1] = 2 : helper\inc[2] = 4
+ helper\inc[3] = 2 : helper\inc[4] = 4 : helper\inc[5] = 6
+ helper\inc[6] = 2 : helper\inc[7] = 6
+
+ Define k.q = 7
+ While k * k <= n
+ If n % k = 0 : ProcedureReturn k : EndIf
+ k + helper\inc[helper\index]
+ helper\index = (helper\index + 1) % 8
+ Wend
+ ProcedureReturn n
+EndProcedure
+
+OpenConsole()
+Define Dim blum.q(49)
+Define.q bc = 0, i = 1
+Define Dim counts.q(9)
+
+Repeat
+ Define p.q = firstPrimeFactor(i)
+ If p % 4 = 3
+ Define q.q = i / p
+ If q <> p And q % 4 = 3 And isPrime(q)
+ If bc < 50 : blum(bc) = i : EndIf
+ counts(i % 10) + 1
+ bc + 1
+
+ If bc = 50
+ PrintN("First 50 Blum integers:")
+ For j = 0 To 49
+ Print(" " + RSet(Str(blum(j)), 3))
+ If (j + 1) % 10 = 0 : PrintN("") : EndIf
+ Next
+ PrintN("")
+ ElseIf bc = 26828 Or bc % 100000 = 0
+ PrintN("The " + RSet(Str(bc), 6) + "th Blum integer is: " + RSet(Str(i), 7))
+ If bc = 400000
+ PrintN(#CRLF$ + "% distribution of the first 400,000 Blum integers:")
+ For j = 1 To 9 Step 2
+ If j <> 5
+ PrintN(RSet(StrF(counts(j)/4000, 3), 5) + "% end in " + Str(j))
+ EndIf
+ Next
+ Break
+ EndIf
+ EndIf
+ EndIf
+ EndIf
+ If i % 5 = 3
+ i + 4
+ Else
+ i + 2
+ EndIf
+ForEver
+
+PrintN(#CRLF$ + "Press ENTER to exit"): Input()
diff --git a/Task/Blum-integer/QB64/blum-integer.qb64 b/Task/Blum-integer/QB64/blum-integer.qb64
new file mode 100644
index 0000000000..9b3a0be158
--- /dev/null
+++ b/Task/Blum-integer/QB64/blum-integer.qb64
@@ -0,0 +1,73 @@
+Dim Shared inc(7) As Integer
+inc(0) = 4: inc(1) = 2: inc(2) = 4
+inc(3) = 2: inc(4) = 4: inc(5) = 6
+inc(6) = 2: inc(7) = 6
+
+Dim blum(49) As Long
+Dim counts(9) As Long
+Dim bc As Long, i As Long, p As Long, q As Long, j As Integer
+i = 1
+
+Do
+ p = firstPrimeFactor(i)
+ If p Mod 4 = 3 Then
+ q = i \ p
+ If q <> p And q Mod 4 = 3 And isPrime(q) Then
+ If bc < 50 Then blum(bc) = i
+ counts(i Mod 10) = counts(i Mod 10) + 1
+ bc = bc + 1
+
+ If bc = 50 Then
+ Print "First 50 Blum integers:"
+ For j = 0 To 49
+ Print Using "####"; blum(j);
+ If (j + 1) Mod 10 = 0 Then Print
+ Next
+ Print
+ ElseIf bc = 26828 Or bc Mod 100000 = 0 Then
+ Print Using "The ###,###th Blum integer is: #,###,###"; bc; i
+ If bc = 400000 Then
+ Print Chr$(10); "% distribution of the first 400,000 Blum integers:"
+ For j = 1 To 9 Step 2
+ If j <> 5 Then
+ Print Using " ##.###% end in #"; (counts(j%) / 4000); j%
+ End If
+ Next
+ End
+ End If
+ End If
+ End If
+ End If
+ If i Mod 5 = 3 Then i = i + 4 Else i = i + 2
+Loop
+End
+
+Function firstPrimeFactor& (n As Long)
+ Dim k As Long, idx As Integer
+ If n = 1 Then firstPrimeFactor& = 1: Exit Function
+ If n Mod 3 = 0 Then firstPrimeFactor& = 3: Exit Function
+ If n Mod 5 = 0 Then firstPrimeFactor& = 5: Exit Function
+ k = 7: idx = 0
+ Do While k * k <= n
+ If n Mod k = 0 Then
+ firstPrimeFactor& = k
+ Exit Function
+ End If
+ k = k + inc(idx)
+ idx = (idx + 1) Mod 8
+ Loop
+ firstPrimeFactor& = n
+End Function
+
+Function isPrime% (n As Long)
+ Dim i As Long
+ If n <= 1 Then Exit Function
+ If n <= 3 Then isPrime% = 1: Exit Function
+ If n Mod 2 = 0 Or n Mod 3 = 0 Then Exit Function
+ i = 5
+ While i * i <= n
+ If n Mod i = 0 Or n Mod (i + 2) = 0 Then Exit Function
+ i = i + 6
+ Wend
+ isPrime% = 1
+End Function
diff --git a/Task/Boyer-Moore-string-search/Free-Pascal-Lazarus/boyer-moore-string-search.pas b/Task/Boyer-Moore-string-search/Free-Pascal-Lazarus/boyer-moore-string-search.pas
new file mode 100644
index 0000000000..2a2772d84a
--- /dev/null
+++ b/Task/Boyer-Moore-string-search/Free-Pascal-Lazarus/boyer-moore-string-search.pas
@@ -0,0 +1,62 @@
+{$mode objfpc}{$H+}
+uses strutils, classes;
+const s:string = 'GCTAGCTCTACGAGTCTA'+ LineEnding +
+ 'GGCTATAATGCGTA'+ LineEnding +
+ 'there would have been a time for such a word'+ LineEnding +
+ 'needle need noodle needle'+ LineEnding +
+ 'DKnuthusesandprogramsanimaginarycomputertheMIXanditsassociatedmachinecodeandassemblylanguages'+ LineEnding +
+ 'Nearby farms grew an acre of alfalfa on the dairy''s behalf, with bales of that alfalfa exchanged for milk.';
+
+var
+ List:TStringlist;
+ matches:SizeIntArray;
+ i:SizeInt;
+begin
+ List := TStringlist.Create;
+ try
+ List.Text := s;
+ if FindMatchesBoyerMooreCaseSensitive(List[0],'TCTA',matches,true) then
+ begin
+ write('TCTA found at index: ');
+ for i in matches do write(i:4);
+ writeln;
+ end else writeln('no matches found');
+
+ if FindMatchesBoyerMooreCaseSensitive(List[1],'TAATAAA',matches,true) then
+ begin
+ write('TAATAAA found at index: ');
+ for i in matches do write(i:4);
+ writeln;
+ end else writeln('no matches found for TAATAAA');
+
+ if FindMatchesBoyerMooreCaseSensitive(List[2],'word',matches,true) then
+ begin
+ write('word found at index: ');
+ for i in matches do write(i:4);
+ writeln;
+ end else writeln('no matches found for word');
+
+ if FindMatchesBoyerMooreCaseSensitive(List[3],'needle',matches,true) then
+ begin
+ write('needle found at index: ');
+ for i in matches do write(i:4);
+ writeln;
+ end else writeln('no matches found for needle');
+
+ if FindMatchesBoyerMooreCaseSensitive(List[4],'and',matches,true) then
+ begin
+ write('and found at index: ');
+ for i in matches do write(i:4);
+ writeln;
+ end else writeln('no matches found for and');
+
+ if FindMatchesBoyerMooreCaseSensitive(List[5],'alfalfa',matches,true) then
+ begin
+ write('alfalfa found at index: ');
+ for i in matches do write(i:4);
+ writeln;
+ end else writeln('no matches found for alfalfa');
+ finally
+ List.Free;
+ end;
+end.
diff --git a/Task/Boyer-Moore-string-search/Pascal/boyer-moore-string-search-1.pas b/Task/Boyer-Moore-string-search/Pascal/boyer-moore-string-search-1.pas
new file mode 100644
index 0000000000..dfbfd37b6c
--- /dev/null
+++ b/Task/Boyer-Moore-string-search/Pascal/boyer-moore-string-search-1.pas
@@ -0,0 +1,2 @@
+FindMatchesBoyerMooreCaseInSensitive;
+FindMatchesBoyerMooreCaseSensitive;
diff --git a/Task/Boyer-Moore-string-search/Pascal/boyer-moore-string-search.pas b/Task/Boyer-Moore-string-search/Pascal/boyer-moore-string-search-2.pas
similarity index 100%
rename from Task/Boyer-Moore-string-search/Pascal/boyer-moore-string-search.pas
rename to Task/Boyer-Moore-string-search/Pascal/boyer-moore-string-search-2.pas
diff --git a/Task/Brilliant-numbers/00-TASK.txt b/Task/Brilliant-numbers/00-TASK.txt
index e17610886b..24c4103983 100644
--- a/Task/Brilliant-numbers/00-TASK.txt
+++ b/Task/Brilliant-numbers/00-TASK.txt
@@ -23,4 +23,5 @@
;See also
;* [https://www.numbersaplenty.com/set/brilliant_number Numbers Aplenty - Brilliant numbers]
+;* [https://www.alpertron.com.ar/BRILLIANT.HTM - Like the task upper Limit 1E201]
;* [[oeis:A078972|OEIS:A078972 - Brilliant numbers: semiprimes whose prime factors have the same number of decimal digits]]
diff --git a/Task/Brilliant-numbers/Free-Pascal-Lazarus/brilliant-numbers.pas b/Task/Brilliant-numbers/Free-Pascal-Lazarus/brilliant-numbers.pas
index c38497d189..d85407517a 100644
--- a/Task/Brilliant-numbers/Free-Pascal-Lazarus/brilliant-numbers.pas
+++ b/Task/Brilliant-numbers/Free-Pascal-Lazarus/brilliant-numbers.pas
@@ -2,227 +2,259 @@ program BrilliantNumbers;
{$IFDEF FPC}
{$MODE Delphi}
{$Optimization ON,All}
+ {$codealign proc=32,loop=1}
{$ENDIF}
{$IFDEF WINDOWS}
{$APPTYPE CONSOLE}
{$ENDIF}
-
uses
- SysUtils,classes;
+ SysUtils,primSieve,classes;
const
- MaxRoot = 100*1000*1000+2310;//+2310 to get next prime beyond limit
+ MaxRoot =1000*1000*1000;
type
- tPrimeDelta = array of Uint8;
+ tPrime = array of Uint32;
+ tpPrime = pUint32;
tBrilliant = record
- pMin, // start for dgtcnt
- pMid, // start for dgtcnt+1
- pMax, // end for dgtcnt+1
+ Count_dgt : Uint64;
MinIdx,
MidIdx,
MaxIdx : Uint32;
end;
var
- BrilliantPos :array [0..8] of TBrilliant;
- OddPowP : Uint32;
+{$ALIGN 32}
+ BrilliantPos :array [0..10] of TBrilliant;
- function BuildWheel(var primes: tPrimeDelta): longint;
- //pre-sieve with small primes,returns the last used prime
+ function commatize(n:NativeUint):string;
var
- //wheelprimes = 2,3,5,7,11. ;wheelsize = product[i= 0..wpno-1]wheelprimes[i] > Uint64|i> 13
- wheelprimes: array[0..15] of byte;
- wheelSize, wpno, pr, pw, i, k: longword;
+ l,i : NativeUint;
begin
- pr := 1;
- primes[1] := 1;
- WheelSize := 1;
- wpno := 0;
- repeat
- Inc(pr);
- pw := pr;
- if pw > wheelsize then
- Dec(pw, wheelsize);
- if Primes[pw]<>0 then
- begin
- k := WheelSize + 1;
- for i := 1 to pr - 1 do
- begin
- Inc(k, WheelSize);
- if k < High(primes) then
- move(primes[1], primes[k - WheelSize], WheelSize)
- else
- begin
- move(primes[1], primes[k - WheelSize], High(primes) - WheelSize * i);
- break;
- end;
- end;
- Dec(k);
- if k > High(primes) then
- k := High(primes);
- wheelPrimes[wpno] := pr;
- primes[pr] := 0;
-
- i := sqr(pr);
- while i <= k do
- begin
- primes[i] := 0;
- Inc(i, pr);
- end;
-
- Inc(wpno);
- WheelSize := k;
- end;
- until WheelSize >= High(primes);
- while wpno > 0 do
- begin
- Dec(wpno);
- primes[wheelPrimes[wpno]] := 1;
+ str(n,result);
+ l := length(result);
+ if l < 4 then
+ exit;
+ i := l+ (l-1) DIV 3;
+ setlength(result,i);
+ While i <> l do
+ Begin
+ result[i]:= result[l];
+ result[i-1]:= result[l-1];
+ result[i-2]:= result[l-2];
+ result[i-3]:= ',';
+ dec(i,4);
+ dec(l,3);
end;
- Result := pr;
end;
- procedure Sieve(var primes: tPrimeDelta);
+ procedure Sieve(var pr: tPrime;n:UInt32);
+ //get primes plus one beyond limit
var
- pPrime: pUint8;
- sieveprime, delFact: longword;
+ pPr : pUInt32;
+ i,p : Int32;
begin
- sieveprime := BuildWheel(primes);
- pPrime := @primes[0];
+ If n> 60184 then
+ //Pierre Dusart proved in 2010
+ setlength(pr,trunc(n/(ln(n)-1.1)))
+ else
+ setlength(pr,6542);
+ i := 0;
+ pPr := @pr[0];
repeat
- repeat
- Inc(sieveprime);
- until pPrime[sieveprime]<>0;
- delFact := High(primes) div sieveprime;
- if delFact < sieveprime then
- BREAK;
- inc(delFact);
- repeat
- repeat
- Dec(delFact);
- until pPrime[delFact]<>0;
- pPrime[sieveprime * delFact] := 0;
- until delFact < sieveprime;
- until False;
- primes[1] := 0;
+ p := NextPrime;
+ pPr[i] := p;
+ i +=1;
+ until p > n;
+ setlength(pr,i);
+ writeln('Primes [',pPr[0],'..',commatize(pPr[i-2]),'] +',commatize(pPr[i-1]));
end;
- procedure GetPrimeDelta(var prD:tPrimeDelta;size: int32);
- var
- pPD : pUint8;
- idx,LastP,p : Uint32;
- Begin
- setlength(prD, 0);
- setlength(prD, size + 1);
- Sieve(prD);
- pPD := @prD[0];
- idx := 0;
- LastP := 0;
- p := 0;
- repeat
- if pPD[p] <> 0 then
- begin
- pPD[idx] := p-LastP;
- LastP := p;
- inc(idx);
- end;
- inc(p);
- until p> Size;
- Setlength(prD,idx);
- end;
-
- function Cnt_First_DgtCnt(pPD:pUint8;lmt:UInt64;dgtCnt: Int32):nativeUint;
- //counting products of prime factors smaller than limit
+ function InsRes(p : tpPrime;Val,MaxIdx,cnt: Int32):int32;
var
- pLo,pHi,iLo,iHi : UInt64;
+ i : Int32;
begin
- with BrilliantPos[dgtCnt] do
+ if cnt = maxIdx then
begin
- pLo := pMin;
- iLO := MinIdx;
- pHi := pMid;
- iHi := MidIdx;
+ while (maxIdx >=0) AND (val < p[maxIdx]) do
+ Begin
+ p[maxIdx+1] := p[maxIdx];
+ dec(maxIdx);
+ end;
+ p[maxIdx+1] := val;
+ EXIT(cnt);
+ end
+ else
+ Begin
+ i := MaxIDx;
+ if val > p[i] then
+ begin
+ p[i+1] := val;
+ end
+ else
+ begin
+ while (i >=0) AND (val < p[i]) do
+ Begin
+ p[i+1] := p[i];
+ dec(i);
+ end;
+ p[i+1] := val;
+ end;
end;
- result := iHi-iLo+1;
- repeat
- iLo+=1;
- pLO := pLo+pPD[iLo];
- if pLo = pHi then
- begin
- if sqr(pLo) < Lmt then
- pLO := pLo+pPD[iLo+1];
- OddPowP := pLo;
- EXIT(result+1);
- end;
- while (pHi >= pLo) AND (pHi*pLo > lmt) do
- begin
- pHi := pHi-pPD[iHi];
- iHi-=1;
- end;
- result += iHi-iLo+1;
- until (pHi < pLo);
- OddPowP := pLo;
+ result := MaxIdx+1;
+ if result > cnt then
+ result := cnt;
end;
- procedure GetLimitPos(pPD:pUint8;MaxPrIdx:NativeUint);
+ procedure Get_N_Brilliant(pPr:tpPrime;cnt:Int32);
var
- lmt, p,pmin,idx1,dgtCnt : nativeuint;
- DeltaMax,DeltaMin,TotCnt: Uint64;
- begin
+ p_p : array of Int32;
+ lmt,p1,p2,i1,i2,maxIdx : Int32;
+ Begin
+ setlength(p_p,cnt+2);
+ MaxIdx := 0;
+ p_p[MaxIdx] := maxint;
+ i1 := 1;
+ p1 := pPr[0];
lmt := 10;
- p := 0;
- idx1 := 0;
- dgtCnt := 0;
- TotCnt := 0;
- p += pPD[idx1];
repeat
- BrilliantPos[dgtCnt].pMin:= p;
- BrilliantPos[dgtCnt].MinIdx := idx1;
- write('10^',2*dgtCnt+1:2,':',p:10);
- pMin := p;
- while (pMin*p < lmt) and (idx1 < MaxPrIdx) do
- begin
- idx1 += 1;
- p += pPD[idx1];
- end;
- pMin := p-pPD[idx1];
- BrilliantPos[dgtCnt].pMid := pMin;
- BrilliantPos[dgtCnt].MidIdx := idx1-1;
- DeltaMin := Cnt_First_DgtCnt(pPD,lmt,dgtCnt);
- writeln(DeltaMin:20,TotCnt+DeltaMin:20);
+ repeat
+ p2 := p1;
+ if MaxIdx = cnt then
+ if p1*p1 > p_p[MaxIdx] then
+ break;
+ i2 := i1;
+ repeat
+ MaxIdx := InsRes(@p_p[0],p1*p2,MaxIdx,cnt);
+ p2 := pPr[i2];
+ i2+=1;
+ if MaxIdx = cnt then
+ if p1*p2 > p_p[MaxIdx] then
+ break;
+ until p2>lmt;
+ p1 := pPr[i1];
+ i1 +=1;
+ until p1>lmt;
lmt *=10;
- while (p*p <= lmt) AND (idx1 < MaxPrIdx) do
- begin
- idx1 += 1;
- p += pPD[idx1];
- end;
- pMin := p-pPD[idx1];
- BrilliantPos[dgtCnt].pMax := pMin;
- BrilliantPos[dgtCnt].MaxIdx := idx1-1;
+ until (MaxIdx = cnt)AND (p1*p1 > p_p[MaxIdx]);
- //for both decimals just summation formula
- deltaMax := idx1-BrilliantPos[dgtCnt].MinIdx;
- deltaMax := (deltaMax*(deltaMax+1) DIV 2);
- TotCnt += deltaMax;
- write('10^',2*dgtCnt+2:2,':',OddPowP:10);
- writeln(DeltaMax-DeltaMin:20,TotCnt:20);
- dgtCnt += 1;
- lmt*=10;
- until (idx1 >= MaxPrIdx) or(lmt>sqr(MaxRoot));
- writeln(p:16);
- end;
+ Writeln('The first ',cnt,' brilliant numbers ');
+ For i1 := 1 to cnt do
+ Begin
+ write(commatize(p_p[i1-1]):6);
+ if i1 MOD 10 = 0 then
+ write(#13#10);
+ end;
+ writeln;
+ end;
+
+ function BinSearch(pPr:tpPrime;maxIdx,p:NativeUint):NativeInt;
+ // binary search for idx , so, that primes[idx-1] < p < primes[idx]
+ var
+ tmp : double;
+ i1,i2,m : nativeUInt;
+ begin
+ //assumption, where to find the right prime
+ tmp := ln(p)-1;
+ i1 := trunc(p/tmp);
+ i2 := trunc(p/(tmp-0.1));
+ IF i2 > MaxIdx then
+ i2 := MaxIdx;
+ repeat
+ m := (i1+i2) shr 1;
+ if pPr[m] MaxIdx then
+ i2 := MaxIdx;
+ while pPr[i2] < p do
+ inc(i2);
+ result := i2;
+ end;
+
+ function Cnt_First_DgtCnt(pPr:tpPrime;lmt:UInt64;dgtCnt: Int32):nativeInt;
+ //counting products of prime factors below limit
+ //and memorize the smallest brilliant number above limit
+ var
+ pLo,tmp,res : UInt64;
+ iLo,iHi : Int64;
+ begin
+ with BrilliantPos[dgtCnt] do
+ begin
+ iLO := MinIdx;
+ iHi := MidIdx;
+ end;
+ result := iHi-iLo;
+ res := pPr[iLo]*pPr[iHi+1];
+ repeat
+ iLo +=1;
+ pLo := pPr[iLo];
+ while (iHi >= iLo) AND (pPr[iHi]*pLo > Lmt) do
+ iHi-=1;
+ tmp := pPr[iHi+1]*pLo;
+ if (tmp>lmt)AND (res>tmp) then
+ res := tmp;
+ result += iHi-iLo+1;
+ until (iHi < iLo);
+ BrilliantPos[dgtCnt].Count_dgt := res;
+ end;
+
+ procedure GetLimitPos(pPr:tpPrime;MaxPrIdx:NativeUint);
+ var
+ lmt, p,idx1,dgtCnt : nativeuint;
+ DeltaMax,DeltaMin,First,TotCnt: Uint64;
+ begin
+ lmt := 10;
+ p := 0;
+ idx1 := 0;
+ dgtCnt := 0;
+ TotCnt := 0;
+ p := pPr[idx1];
+ repeat
+ BrilliantPos[dgtCnt].MinIdx := idx1;
+ write(2*dgtCnt+1:3,':');
+ First := p*p;
+ p := Lmt DIV p;
+ if p> 60000 then
+ idx1:= BinSearch(pPr,MaxPrIdx,p)
+ else
+ while (p>pPr[idx1]) and (idx1 < MaxPrIdx) do
+ idx1 += 1;
+ BrilliantPos[dgtCnt].MidIdx := idx1;
+ DeltaMin := Cnt_First_DgtCnt(pPr,lmt,dgtCnt);
+ writeln(commatize(TotCnt+DeltaMin):23,commatize(First):24);
+ lmt *=10;
+ repeat
+ idx1 +=1;
+ until (sqr(pPr[idx1]) >= lmt)OR (idx1>=MaxPrIdx);
+ p := pPr[idx1];
+ BrilliantPos[dgtCnt].MaxIdx := idx1-1;
+ //for both decimals just summation formula
+ deltaMax := idx1-BrilliantPos[dgtCnt].MinIdx;
+ deltaMax := (deltaMax*(deltaMax+1) DIV 2);
+ TotCnt += deltaMax;
+ First := BrilliantPos[dgtCnt].Count_dgt;
+ write(2*dgtCnt+2:3,':');
+ writeln(commatize(TotCnt):23,commatize(First):24);
+ dgtCnt += 1;
+ lmt*=10;
+ until (idx1 >= MaxPrIdx) or(lmt>sqr(MaxRoot));
+ end;
var
- primeDelta :TprimeDelta;
+ primes :tPrime;
+ pPr : tpPrime;
T : INt64;
- pPD : pUint8;
begin
T := GetTickCount64;
- GetPrimeDelta(primeDelta,MaxRoot);
+ Sieve(primes,MaxRoot);
Writeln('Sieving in ',GetTickCount64-T,' ms');
T := GetTickCount64;
- pPD := @primeDelta[0];
-// 10^ 1: 2 3 3
- writeln('Limit first prime deltaCount Total Count');
- GetLimitPos(pPD,High(primeDelta));
+
+ pPr := @primes[0];
+ Get_N_Brilliant(pPr,100);
+ writeln('Digits total count first brilliant');
+ GetLimitPos(pPr,High(primes));
+ writeln(' ',Commatize(sqr(primes[High(primes)])):26);
Writeln('Counting in ',GetTickCount64-T,' ms');
{$IFDEF WINDOWS}
readln;
diff --git a/Task/Brownian-tree/FutureBasic/brownian-tree.basic b/Task/Brownian-tree/FutureBasic/brownian-tree.basic
new file mode 100644
index 0000000000..a394c348c4
--- /dev/null
+++ b/Task/Brownian-tree/FutureBasic/brownian-tree.basic
@@ -0,0 +1,153 @@
+// Brownian tree
+//https://rosettacode.org/wiki/Brownian_tree
+
+/*
+A Brownian tree is built with these steps:
+first, a "seed" is placed somewhere on the screen.
+Then, a particle is placed in a random position of the screen,
+and moved randomly until it bumps against the seed.
+The particle is left there, and another particle is placed in a random position
+and moved until it bumps against the seed or any previous particle, and so on.
+
+*/
+
+
+begin globals
+
+ _w = 400 // window size
+ short w = _w
+ bool pixelUsed(_w ,_w )
+ short x, y , Oldx, Oldy
+ cgRect TheRect
+ short Edge
+ long SpeckleCount
+ short MainColor,SpeckleColor
+ bool GreenGreen,WhiteWhite,WhiteIndigo,WhiteMagenta,GreenIndigo,CyanBlue
+ bool SeedPlanted
+ long count
+
+
+ // Color Options
+ GreenGreen = 0
+ GreenIndigo = 0
+ WhiteIndigo = 1
+ WhiteWhite = 0
+ WhiteMagenta = 0
+ CyanBlue = 0
+
+ if GreenGreen then MainColor = _ZGreen : SpeckleColor = _ZGreen
+ if WhiteWhite then MainColor = _ZWhite : SpeckleColor = _ZWhite
+ if WhiteIndigo then MainColor = _ZWhite : SpeckleColor = _zSystemIndigo
+ if WhiteMagenta then MainColor = _ZWhite : SpeckleColor = _zMagenta
+ if GreenIndigo then MainColor = _ZGreen : SpeckleColor = _zSystemIndigo
+ if CyanBlue then MainColor = _zCyan : SpeckleColor = _zBlue
+
+end globals
+
+_Window = 1
+window _Window, @"", ( 0, 0, _w, _w ), NSWindowStyleMaskTitled + NSWindowStyleMaskMiniaturizable
+
+windowcenter(_Window)
+WindowSetBackgroundColor(_Window,fn ColorBlack)
+
+local fn ClearPixelArray
+ cls
+
+ short row,col
+ for row = 1 to 400
+ for col = 1 to 400
+ pixelUsed(row,col) = NO
+ next
+ next
+
+
+ SpeckleCount = 0
+
+ Edge = _w
+ /// place seed in the middle
+ pen -1
+ oval fill (w/2,w/2,5,5), MainColor
+ x = w/2
+ y = w/2
+ pixelUsed(x,y) = YES
+
+ Oldx = x
+ Oldy = y
+ count = 0
+ SeedPlanted = _true
+
+end fn
+
+
+local fn DrawPixels
+
+ // Set New Random particle location
+ if SeedPlanted = _false
+ do
+ x = rnd(Edge)
+ y = rnd(Edge)
+ until pixelUsed(x,y) = NO
+ end if
+
+ SeedPlanted = _false
+ short xBack, yBack
+ xBack = x
+ yBack = x
+
+
+ // Find a location for the new particle
+ do
+
+ Oldx = x
+ Oldy = y
+
+ // set x and y within plus or minus 15 pixels of x or y
+ x += RND(3) - 2
+ y += RND(3) - 2
+
+ // prevent results that are not within 15 pixels of Oldx and Oldy
+ if x <= 0 then x = xBack : y = yBack
+ if y <= 0 then y = xBack : y = yBack
+ if x > Edge then x = xBack : y = yBack
+ if y > Edge then y = xBack : y = yBack
+
+ until pixelUsed(x,y) = YES
+
+
+ // Draw the new particle but protect the margin on the edge
+
+ if Oldx > 15 && Oldx < Edge - 15 && Oldy > 15 && Oldy < Edge - 15
+ SpeckleCount ++
+
+ pen -1
+ if SpeckleCount < 200
+ oval fill (Oldx,Oldy,1,1), MainColor
+ else
+ oval fill (Oldx,Oldy,2,2), SpeckleColor
+ SpeckleCount = 0
+ end if
+
+ pixelUsed(Oldx,Oldy) = YES
+ xBack = x
+ yBack = y
+ count ++
+ end if
+
+
+ if count > 10000
+ CFStringRef ReturnedKey
+ ReturnedKey = Inkey %(90,1),@"Any key for another one. Q to quit"
+ if fn StringContainsString(ReturnedKey, @"q") then end
+ if fn StringContainsString(ReturnedKey, @"Q") then end
+ fn ClearPixelArray
+ end if
+
+
+end fn
+
+
+fn ClearPixelArray
+
+fn AppSetTimer( .000001, @Fn DrawPixels, _true )
+
+handleevents
diff --git a/Task/Bulls-and-cows/J/bulls-and-cows-2.j b/Task/Bulls-and-cows/J/bulls-and-cows-2.j
index 0fb16de9c6..9795e742c7 100644
--- a/Task/Bulls-and-cows/J/bulls-and-cows-2.j
+++ b/Task/Bulls-and-cows/J/bulls-and-cows-2.j
@@ -1,4 +1,4 @@
-U =. {{]F.(u[_2:Z:v)}} NB. apply u until v is true
+U =. {{u^:(-.@:v)^:_.}} NB. apply u until v is true
input =. 1!:1@1@echo@'Guess: '
output =. [ ('Bulls: ',:'Cows: ')echo@,.":@,.
isdigits=. *./@e.&'0123456789'
diff --git a/Task/Burrows-Wheeler-transform/ALGOL-68/burrows-wheeler-transform.alg b/Task/Burrows-Wheeler-transform/ALGOL-68/burrows-wheeler-transform.alg
new file mode 100644
index 0000000000..a401340fef
--- /dev/null
+++ b/Task/Burrows-Wheeler-transform/ALGOL-68/burrows-wheeler-transform.alg
@@ -0,0 +1,63 @@
+BEGIN # Burrows-Wheeler transform - translated from the EasyLang sample #
+ PR read "sort.incl.a68" PR # include sort utilities #
+ CHAR stx = REPR 2, etx = REPR 3;
+ OP BWT = ( STRING s )STRING:
+ BEGIN
+ [ LWB s : UPB s + 2 ]STRING tbl;
+ STRING ss = stx + s + etx;
+ FOR i FROM LWB ss TO UPB ss DO
+ STRING a = ss[ LWB ss : i ];
+ STRING b = IF i >= UPB ss THEN "" ELSE ss[ i + 1 : ] FI;
+ tbl[ i ] := b + a
+ OD;
+ QUICKSORT tbl;
+ STRING r := "";
+ FOR s pos FROM LWB tbl TO UPB tbl DO
+ r +:= tbl[ s pos ][ UPB tbl[ s pos ] ]
+ OD;
+ r
+ END # BWT # ;
+ OP IBWT = ( STRING r )STRING:
+ BEGIN
+ [ LWB r : UPB r ]STRING tbl;
+ FOR j FROM LWB r TO UPB r DO tbl[ j ] := "" OD;
+ FROM LWB r TO UPB r DO
+ FOR k FROM LWB r TO UPB r DO
+ r[ k ] +=: tbl[ k ]
+ OD;
+ QUICKSORT tbl
+ OD;
+ STRING result := "";
+ FOR r pos FROM LWB tbl TO UPB tbl WHILE result = "" DO
+ STRING row = tbl[ r pos ];
+ IF row[ UPB row ] = etx THEN result := row[ LWB row + 1 : UPB row - 1 ] FI
+ OD;
+ result
+ END # IBWT # ;
+
+ BEGIN
+ OP XTX = ( STRING s )STRING: # make stx and etx visible #
+ BEGIN
+ STRING result := "";
+ FOR s pos FROM LWB s TO UPB s DO
+ CHAR c = s[ s pos ];
+ result +:= IF c = stx THEN ""
+ ELIF c = etx THEN ""
+ ELSE c
+ FI
+ OD;
+ result
+ END # XTX # ;
+ []STRING tests = ( "banana", "appellee", "dogwood"
+ , "TO BE OR NOT TO BE OR WANT TO BE OR NOT?"
+ , "SIX.MIXED.PIXIES.SIFT.SIXTY.PIXIE.DUST.BOXES"
+ );
+ FOR t pos FROM LWB tests TO UPB tests DO
+ STRING s = tests[ t pos ];
+ print( ( s, newline ) );
+ STRING h = BWT s;
+ print( ( " -> ", XTX h, newline ) );
+ print( ( IBWT h, newline, newline ) )
+ OD
+ END
+END
diff --git a/Task/Burrows-Wheeler-transform/Fortran/burrows-wheeler-transform.f b/Task/Burrows-Wheeler-transform/Fortran/burrows-wheeler-transform.f
new file mode 100644
index 0000000000..8fcb501e51
--- /dev/null
+++ b/Task/Burrows-Wheeler-transform/Fortran/burrows-wheeler-transform.f
@@ -0,0 +1,163 @@
+program BurrowsWheeler
+ implicit none
+
+ ! Main program
+ call Test("BANANA")
+ call Test("CANAAN")
+ call Test("CANCAN")
+ call Test("appellee")
+ call Test("dogwood")
+ call Test("TO BE OR NOT TO BE OR WANT TO BE OR NOT?")
+ call Test("SIX.MIXED.PIXIES.SIFT.SIXTY.PIXIE.DUST.BOXES")
+ call Test("Four score and 7 years ago, our forefathers set forth on this continent to establish a new nation "//&
+ "conceived in liberty and dedicated to he proposition that all men were created equal")
+ contains
+ ! Function to compare rotations
+ integer function CompareRotations(input, n, a, b)
+ character(len=*), intent(in) :: input
+ integer, intent(in) :: n, a, b
+ integer :: p, q, nrNotTested
+ integer :: i ,k
+
+ CompareRotations = 0
+ p = a
+ q = b
+ nrNotTested = n
+ do
+ p = p + 1
+ if (p == n) p = 0
+ q = q + 1
+ if (q == n) q = 0
+ i = p + 1
+ k = q + 1
+ if (input(i:i) == input(k:k)) then
+ nrNotTested = nrNotTested - 1
+ else if (input(i:i) > input(k:k)) then
+ CompareRotations = 1
+ exit
+ else
+ CompareRotations = -1
+ exit
+ end if
+ if (nrNotTested == 0) exit
+ end do
+ end function CompareRotations
+
+ ! Subroutine to encode the input string
+ subroutine Encode(input, encoded, index)
+ character(len=*), intent(in) :: input
+ character(len=*), intent(out) :: encoded
+ integer, intent(out) :: index
+ integer :: n, i, j, k, incr, v
+ integer, allocatable :: perm(:)
+
+ n = len(input)
+ allocate(perm(0:n-1))
+ do j = 0, n - 1
+ perm(j) = j
+ end do
+
+ ! Shell sort
+ incr = 1
+ do
+ incr = 3 * incr + 1
+ if (incr >= n) exit
+ end do
+ do
+ incr = incr / 3
+ do i = incr, n - 1
+ v = perm(i)
+ j = i
+ do while (j >= incr)
+ if(CompareRotations(input, n, perm(j - incr), v) /= 1)exit
+ perm(j) = perm(j - incr)
+ j = j - incr
+ end do
+ perm(j) = v
+ end do
+ if (incr == 1) exit
+ end do
+
+ ! Create the output
+ do j = 0, n - 1
+ k = perm(j)
+ encoded(j + 1:j + 1) = input(k + 1:k + 1)
+ if (k == n - 1) index = j
+ end do
+
+ deallocate(perm)
+ end subroutine Encode
+
+ ! Function to decode the encoded string
+ function Decode(encoded, index) result(decoded)
+ character(len=*), intent(in) :: encoded
+ integer, intent(in) :: index
+ character(len=:), allocatable :: decoded
+ integer :: charInfo(0:255)
+ integer, allocatable :: perm(:)
+ integer :: n, j, k, total, prev
+ character :: c
+
+ n = len(encoded)
+ if (n == 0) then
+ decoded = ""
+ return
+ end if
+
+ charInfo = 0
+ do j = 0, n - 1
+ c = encoded(j + 1:j + 1)
+ charInfo(ichar(c)) = charInfo(ichar(c)) + 1
+ end do
+
+ total = 0
+ prev = 0
+ do k = 0, 255
+ total = total + prev
+ prev = charInfo(k)
+ charInfo(k) = total
+ end do
+
+ allocate(perm(0:n-1))
+ do j = 0, n - 1
+ c = encoded(j + 1:j + 1)
+ k = charInfo(ichar(c))
+ perm(k) = j
+ charInfo(ichar(c)) = charInfo(ichar(c)) + 1
+ end do
+
+ allocate(character(len=n) :: decoded)
+ k = 0
+ j = index
+ do
+ j = perm(j)
+ decoded(k + 1:k + 1) = encoded(j + 1:j + 1)
+ k = k + 1
+ if (j == index) exit
+ end do
+
+ if (k < n) then
+ do j = k, n - 1
+ decoded(j + 1:j + 1) = decoded(j - k + 1:j - k + 1)
+ end do
+ end if
+ end function Decode
+
+ ! Subroutine to test the encoding and decoding
+ subroutine Test(s)
+ character(len=*), intent(in) :: s
+ character(len=:), allocatable :: encoded, decoded
+ integer :: index
+
+ print *, ""
+ print *, " ", s
+ allocate(character(len=len(s)) :: encoded)
+ call Encode(s, encoded, index)
+ print *, "---> ", encoded
+ print *, " index = ", index
+ decoded = Decode(encoded, index)
+ print *, "---> ", decoded
+ deallocate(encoded)
+ end subroutine Test
+
+end program BurrowsWheeler
diff --git a/Task/CRC-32/M2000-Interpreter/crc-32-1.m2000 b/Task/CRC-32/M2000-Interpreter/crc-32-1.m2000
index 52eb55078b..c6073ef05e 100644
--- a/Task/CRC-32/M2000-Interpreter/crc-32-1.m2000
+++ b/Task/CRC-32/M2000-Interpreter/crc-32-1.m2000
@@ -1,25 +1,30 @@
-Module CheckIt {
- Function PrepareTable {
- Dim Base 0, table(256)
- For i = 0 To 255 {
- k = i
- For j = 0 To 7 {
- If binary.and(k,1)=1 Then {
- k =binary.Xor(binary.shift(k, -1) , 0xEDB88320)
- } Else k=binary.shift(k, -1)
- }
- table(i) = k
- }
- =table()
- }
- crctable=PrepareTable()
- crc32= lambda crctable (buf$) -> {
- crc =0xFFFFFFFF
- For i = 0 To Len(buf$) -1
- crc = binary.xor(binary.shift(crc, -8), array(crctable, binary.xor(binary.and(crc, 0xff), asc(mid$(buf$, i+1, 1)))))
- Next i
- =0xFFFFFFFF-crc
- }
- Print crc32("The quick brown fox jumps over the lazy dog")=0x414fa339
+odule CheckIt {
+ crc32 = lambda ->{
+ Function PrepareTable {
+ buffer t as long * 256
+ For i = 0 To 255
+ k = i
+ For j = 0 To 7
+ If binary.and(k,1)=1 Then
+ k =binary.Xor(binary.shift(k, -1) , 0xEDB88320)
+ Else
+ k=binary.shift(k, -1)
+ End If
+ Next
+ Return t, i:=k
+ Next
+ =t
+ }
+ = lambda crctable=PrepareTable() (c, buf$) -> {
+ crc=0xFFFFFFFF-c
+ For i = 1 To Len(buf$)
+ crc = binary.xor(binary.shift(crc, -8), eval(crctable, binary.xor(binary.and(crc, 0xff), asc(mid$(buf$, i, 1)))))
+ Next i
+ =0xFFFFFFFF-crc
+ }
+ }() ' execute now
+ Print crc32(0, "The quick brown fox jumps over the lazy dog")=0x414fa339&
+ Print crc32(crc32(0, "The quick brown fox jumps"), " over the lazy dog")=0x414fa339&
+ Print crc32(crc32(crc32(0, "The qu"), "ick brown"), " fox jumps over the lazy dog")=0x414fa339&
}
CheckIt
diff --git a/Task/CRC-32/Zig/crc-32.zig b/Task/CRC-32/Zig/crc-32.zig
index 10a6bf31c1..629dbde918 100644
--- a/Task/CRC-32/Zig/crc-32.zig
+++ b/Task/CRC-32/Zig/crc-32.zig
@@ -2,6 +2,6 @@ const std = @import("std");
const Crc32Ieee = std.hash.Crc32;
pub fn main() !void {
- var res: u32 = Crc32Ieee.hash("The quick brown fox jumps over the lazy dog");
+ const res: u32 = Crc32Ieee.hash("The quick brown fox jumps over the lazy dog");
std.debug.print("{x}\n", .{res});
}
diff --git a/Task/CSV-data-manipulation/Lua/csv-data-manipulation-1.lua b/Task/CSV-data-manipulation/Lua/csv-data-manipulation-1.lua
new file mode 100644
index 0000000000..38f23efa69
--- /dev/null
+++ b/Task/CSV-data-manipulation/Lua/csv-data-manipulation-1.lua
@@ -0,0 +1,13 @@
+-- Lua has no built in methods to handle csv files.
+-- it does have string.gmatch, which we use to global.match whatever isn't a comma
+
+print(io.read"l" .. ",SUM")
+for line in io.lines() do
+ local fields, sum = {}, 0
+ for field in line:gmatch"[^,]+" do
+ table.insert(fields, field)
+ sum = sum + field
+ end
+ table.insert(fields, sum)
+ print(table.concat(fields,","))
+end
diff --git a/Task/CSV-data-manipulation/Lua/csv-data-manipulation-2.lua b/Task/CSV-data-manipulation/Lua/csv-data-manipulation-2.lua
new file mode 100644
index 0000000000..0469930ba1
--- /dev/null
+++ b/Task/CSV-data-manipulation/Lua/csv-data-manipulation-2.lua
@@ -0,0 +1,26 @@
+local csv={}
+
+-- read csv file, save records and fields into table
+for line in io.lines('file.csv') do
+ local fields = {}
+ for field in line:gmatch"[^,]+" do
+ table.insert(fields, tonumber(field) or field)
+ end
+ table.insert(csv, fields)
+end
+
+-- change csv values
+table.insert(csv[1], 'SUM')
+for i=2,#csv do
+ local sum=0
+ for _, val in ipairs(csv[i]) do
+ sum = sum + val
+ end
+ table.insert(csv[i], sum)
+end
+
+-- Save
+local fileHandler = io.open('file.csv', 'w')
+for NR, fields in ipairs(csv) do
+ fileHandler:write(table.concat(fields,","), "\n")
+end
diff --git a/Task/CSV-data-manipulation/Lua/csv-data-manipulation.lua b/Task/CSV-data-manipulation/Lua/csv-data-manipulation.lua
deleted file mode 100644
index 26ddaeabc9..0000000000
--- a/Task/CSV-data-manipulation/Lua/csv-data-manipulation.lua
+++ /dev/null
@@ -1,31 +0,0 @@
-local csv={}
-for line in io.lines('file.csv') do
- table.insert(csv, {})
- local i=1
- for j=1,#line do
- if line:sub(j,j) == ',' then
- table.insert(csv[#csv], line:sub(i,j-1))
- i=j+1
- end
- end
- table.insert(csv[#csv], line:sub(i,j))
-end
-
-table.insert(csv[1], 'SUM')
-for i=2,#csv do
- local sum=0
- for j=1,#csv[i] do
- sum=sum + tonumber(csv[i][j])
- end
- if sum>0 then
- table.insert(csv[i], sum)
- end
-end
-
-local newFileData = ''
-for i=1,#csv do
- newFileData=newFileData .. table.concat(csv[i], ',') .. '\n'
-end
-
-local file=io.open('file.csv', 'w')
-file:write(newFileData)
diff --git a/Task/CSV-to-HTML-translation/JavaScript/csv-to-html-translation-4.js b/Task/CSV-to-HTML-translation/JavaScript/csv-to-html-translation-4.js
new file mode 100644
index 0000000000..1124a5e5d1
--- /dev/null
+++ b/Task/CSV-to-HTML-translation/JavaScript/csv-to-html-translation-4.js
@@ -0,0 +1,40 @@
+function csvToHtml(input) {
+ if (!input || typeof input !== 'string') {
+ throw new Error('Invalid input!');
+ }
+
+ function _createTableCell(cellContents, index) {
+ if (!cellContents || typeof cellContents !== 'string') {
+ throw new Error('Invalid data!');
+ }
+
+ const tableCell = document.createElement(
+ (index === 0) ? 'th' : 'td'
+ );
+
+ tableCell.textContent = cellContents.trim();
+ return tableCell;
+ }
+
+ const rows = input.split('\n');
+ const table = document.createElement('table');
+
+ rows.forEach((row, index) => {
+ const tableRow = document.createElement('tr');
+ const tableCells = row.split(',');
+
+ tableCells.forEach((cell) => {
+ try {
+ tableRow.appendChild(
+ _createTableCell(cell, index),
+ );
+ } catch (error) {
+ console.error(error);
+ }
+ });
+
+ table.appendChild(tableRow);
+ });
+
+ return table;
+}
diff --git a/Task/CSV-to-HTML-translation/JavaScript/csv-to-html-translation-5.js b/Task/CSV-to-HTML-translation/JavaScript/csv-to-html-translation-5.js
new file mode 100644
index 0000000000..986924331b
--- /dev/null
+++ b/Task/CSV-to-HTML-translation/JavaScript/csv-to-html-translation-5.js
@@ -0,0 +1,14 @@
+const inputData = `Character,Speech
+The multitude,The messiah! Show us the messiah!
+Brians mother,Now you listen here! He's not the messiah; he's a very naughty boy! Now go away!
+The multitude,Who are you?
+Brians mother,I'm his mother; that's who!
+The multitude,Behold his mother! Behold his mother!`;
+
+try {
+ document.body.append(
+ csvToHtml(inputData),
+ );
+} catch (error) {
+ console.error(error)
+}
diff --git a/Task/CUSIP/Langur/cusip-1.langur b/Task/CUSIP/Langur/cusip-1.langur
index 544bb91265..df07bf5a9d 100644
--- a/Task/CUSIP/Langur/cusip-1.langur
+++ b/Task/CUSIP/Langur/cusip-1.langur
@@ -6,7 +6,7 @@ val isCusip = fn(s) {
val basechars = '0'..'9' ~ 'A'..'Z' ~ "*@#"
val sum = for[=0] i of 8 {
- var v = index(s2s(s, i), basechars)
+ var v = index(basechars, by=s2s(s, of=i))
if not v: return false
v = v[1]-1
if i div 2: v *= 2
diff --git a/Task/Caesar-cipher/Langur/caesar-cipher.langur b/Task/Caesar-cipher/Langur/caesar-cipher.langur
index 3161281621..7b3a36cc20 100644
--- a/Task/Caesar-cipher/Langur/caesar-cipher.langur
+++ b/Task/Caesar-cipher/Langur/caesar-cipher.langur
@@ -1,5 +1,5 @@
val rot = fn(s, key) {
- cp2s map(fn(c) { rotate(rotate(c, key, 'a'..'z'), key, 'A'..'Z') }, s2cp(s))
+ cp2s map(s2cp(s), by=fn(c) { rotate(rotate(c, distance=key, range='a'..'z'), distance=key, range='A'..'Z') })
}
val s = "A quick brown fox jumped over something, you know."
diff --git a/Task/Calculating-the-value-of-e/ALGOL-W/calculating-the-value-of-e.alg b/Task/Calculating-the-value-of-e/ALGOL-W/calculating-the-value-of-e.alg
new file mode 100644
index 0000000000..2e559bfec8
--- /dev/null
+++ b/Task/Calculating-the-value-of-e/ALGOL-W/calculating-the-value-of-e.alg
@@ -0,0 +1,16 @@
+begin % calculate an approximation to e %
+ long real epsilon;
+ long real e0, e, f;
+ integer n;
+ epsilon := 1'-14; f := 1; e := n := 2;
+ while begin
+ e0 := e;
+ f := f * n;
+ n := n + 1;
+ e := e + 1.0 / f;
+ abs ( e - e0 ) >= epsilon
+ end do begin end;
+ write( I_w := 1, s_w := 0, r_format := "A", r_w := 16, r_d := 14 % <-- sets output formatting %
+ , "e = ", e, " after ", n - 1, " iterations"
+ )
+end.
diff --git a/Task/Calculating-the-value-of-e/EDSAC-order-code/calculating-the-value-of-e-1.edsac b/Task/Calculating-the-value-of-e/EDSAC-order-code/calculating-the-value-of-e-1.edsac
index 84c31ea9eb..d51b3a4a5e 100644
--- a/Task/Calculating-the-value-of-e/EDSAC-order-code/calculating-the-value-of-e-1.edsac
+++ b/Task/Calculating-the-value-of-e/EDSAC-order-code/calculating-the-value-of-e-1.edsac
@@ -1,5 +1,6 @@
[Calculate e]
[EDSAC program, Initial Orders 2]
+ [2024-12-25 Bug fix: ensure sandwich bit in 35-bit constant is 0]
[Library subroutine M3. Prints header and is then overwritten]
[Here, last character sets teleprinter to figures]
@@ -29,6 +30,8 @@
GK [set @ (theta) for relative addresses]
[0] PF PF [build sum 4*(1/3! + 1/4! + 1/5! + ...)]
[2] PF PF [term in sum]
+ T4#ZPF [load time: clear whole of #4, including sandwich bit]
+ T4Z [load time: resume normal loading]
[4] PD PF [2^-34, stop when term < this]
[6] PF [divisor]
[7] IF [1/2]
diff --git a/Task/Calculating-the-value-of-e/Haskell/calculating-the-value-of-e-1.hs b/Task/Calculating-the-value-of-e/Haskell/calculating-the-value-of-e-1.hs
index e7ff6b2acd..d43cad0693 100644
--- a/Task/Calculating-the-value-of-e/Haskell/calculating-the-value-of-e-1.hs
+++ b/Task/Calculating-the-value-of-e/Haskell/calculating-the-value-of-e-1.hs
@@ -1,8 +1,7 @@
------ APPROXIMATION OF E OBTAINED AFTER N ITERATIONS ----
eApprox :: Int -> Double
-eApprox n =
- (sum . take n) $ (1 /) <$> scanl (*) 1 [1 ..]
+eApprox n = sum . map (1 /) $ scanl (*) 1 [1..n]
--------------------------- TEST -------------------------
main :: IO ()
diff --git a/Task/Calculating-the-value-of-e/Haskell/calculating-the-value-of-e-3.hs b/Task/Calculating-the-value-of-e/Haskell/calculating-the-value-of-e-3.hs
index 3b9b856f95..a13155388a 100644
--- a/Task/Calculating-the-value-of-e/Haskell/calculating-the-value-of-e-3.hs
+++ b/Task/Calculating-the-value-of-e/Haskell/calculating-the-value-of-e-3.hs
@@ -1,16 +1,4 @@
-{-# LANGUAGE TupleSections #-}
-
-------------------- APPROXIMATIONS TO E ------------------
-
-approximatEs :: [Double]
-approximatEs =
- fst
- <$> iterate
- ( \(e, (i, n)) ->
- (,) . (e +) . (1 /) <*> (succ i,) $ i * n
- )
- (1, (1, 1))
-
---------------------------- TEST -------------------------
-main :: IO ()
-main = print $ approximatEs !! 17
+eApprox n = snd $ foldr f (1, 1) [n, pred n .. 1]
+ where
+ f x (fl, e) =
+ let y = fl * x in (y, e + 1 / y)
diff --git a/Task/Calculating-the-value-of-e/Haskell/calculating-the-value-of-e-4.hs b/Task/Calculating-the-value-of-e/Haskell/calculating-the-value-of-e-4.hs
new file mode 100644
index 0000000000..3b9b856f95
--- /dev/null
+++ b/Task/Calculating-the-value-of-e/Haskell/calculating-the-value-of-e-4.hs
@@ -0,0 +1,16 @@
+{-# LANGUAGE TupleSections #-}
+
+------------------- APPROXIMATIONS TO E ------------------
+
+approximatEs :: [Double]
+approximatEs =
+ fst
+ <$> iterate
+ ( \(e, (i, n)) ->
+ (,) . (e +) . (1 /) <*> (succ i,) $ i * n
+ )
+ (1, (1, 1))
+
+--------------------------- TEST -------------------------
+main :: IO ()
+main = print $ approximatEs !! 17
diff --git a/Task/Calendar/EasyLang/calendar.easy b/Task/Calendar/EasyLang/calendar.easy
index 72c2661b82..b785fed23d 100644
--- a/Task/Calendar/EasyLang/calendar.easy
+++ b/Task/Calendar/EasyLang/calendar.easy
@@ -1,4 +1,5 @@
year = 1969
+# year = number substr timestr systime 1 4
#
wkdays$ = "Su Mo Tu We Th Fr Sa"
pagewide = 80
diff --git a/Task/Call-a-foreign-language-function/C/call-a-foreign-language-function-1.c b/Task/Call-a-foreign-language-function/C/call-a-foreign-language-function-1.c
deleted file mode 100644
index c37f86a156..0000000000
--- a/Task/Call-a-foreign-language-function/C/call-a-foreign-language-function-1.c
+++ /dev/null
@@ -1,24 +0,0 @@
-#include
-#include
-
-int main(int argc,char** argv) {
-
- int arg1 = atoi(argv[1]), arg2 = atoi(argv[2]), sum, diff, product, quotient, remainder ;
-
- __asm__ ( "addl %%ebx, %%eax;" : "=a" (sum) : "a" (arg1) , "b" (arg2) );
- __asm__ ( "subl %%ebx, %%eax;" : "=a" (diff) : "a" (arg1) , "b" (arg2) );
- __asm__ ( "imull %%ebx, %%eax;" : "=a" (product) : "a" (arg1) , "b" (arg2) );
-
- __asm__ ( "movl $0x0, %%edx;"
- "movl %2, %%eax;"
- "movl %3, %%ebx;"
- "idivl %%ebx;" : "=a" (quotient), "=d" (remainder) : "g" (arg1), "g" (arg2) );
-
- printf( "%d + %d = %d\n", arg1, arg2, sum );
- printf( "%d - %d = %d\n", arg1, arg2, diff );
- printf( "%d * %d = %d\n", arg1, arg2, product );
- printf( "%d / %d = %d\n", arg1, arg2, quotient );
- printf( "%d %% %d = %d\n", arg1, arg2, remainder );
-
- return 0 ;
-}
diff --git a/Task/Call-a-foreign-language-function/C/call-a-foreign-language-function-2.c b/Task/Call-a-foreign-language-function/C/call-a-foreign-language-function-2.c
deleted file mode 100644
index f6729d9aa6..0000000000
--- a/Task/Call-a-foreign-language-function/C/call-a-foreign-language-function-2.c
+++ /dev/null
@@ -1,16 +0,0 @@
-#include
-
-int main()
-{
- Py_Initialize();
- PyRun_SimpleString("a = [3*x for x in range(1,11)]");
-
- PyRun_SimpleString("print 'First 10 multiples of 3 : ' + str(a)");
-
- PyRun_SimpleString("print 'Last 5 multiples of 3 : ' + str(a[5:])");
-
- PyRun_SimpleString("print 'First 10 multiples of 3 in reverse order : ' + str(a[::-1])");
-
- Py_Finalize();
- return 0;
-}
diff --git a/Task/Call-a-foreign-language-function/C/call-a-foreign-language-function.c b/Task/Call-a-foreign-language-function/C/call-a-foreign-language-function.c
new file mode 100644
index 0000000000..4e0643695b
--- /dev/null
+++ b/Task/Call-a-foreign-language-function/C/call-a-foreign-language-function.c
@@ -0,0 +1,35 @@
+#include
+#include
+#include
+
+#include
+#include
+
+const char * const lua_code = "print('tau = ' .. 8*math.atan(1))";
+
+int
+main(void)
+{
+ lua_State* L;
+
+ /* initialize lua */
+ L = luaL_newstate();
+ luaL_openlibs(L); /* allows use of lua's standard libraries e.g. math */
+
+ /* load and run the code */
+ if (luaL_loadstring(L, lua_code) != LUA_OK) {
+ fprintf(stderr, "Error loading lua code\n");
+ return EXIT_FAILURE;
+ }
+
+ if (lua_pcall(L, 0, 0, 0) != LUA_OK) {
+ fprintf(stderr, "Error running lua code\n");
+ return EXIT_FAILURE;
+ }
+
+ /* tidy up */
+ lua_pop(L, lua_gettop(L));
+ lua_close(L);
+
+ return 0;
+}
diff --git a/Task/Call-a-foreign-language-function/M2000-Interpreter/call-a-foreign-language-function-5.m2000 b/Task/Call-a-foreign-language-function/M2000-Interpreter/call-a-foreign-language-function-5.m2000
index 7a98009d84..a8f20f1814 100644
--- a/Task/Call-a-foreign-language-function/M2000-Interpreter/call-a-foreign-language-function-5.m2000
+++ b/Task/Call-a-foreign-language-function/M2000-Interpreter/call-a-foreign-language-function-5.m2000
@@ -1,14 +1,14 @@
Module checkit {
Static DisplayOnce=0
- N=100000
+ N=1000000
Read ? N
Form 60
Pen 14
Background { Cls 5}
Cls 5
- \\ use f1 do unload lib - because only New statemend unload it
+ ' use f1 do unload lib - because only New statemend unload it
FKEY 1,"save ctst1:new:load ctst1"
- \\ We use a function as string container, because c code can easy color decorated in M2000.
+ ' We use a function as string container, because c code can easy color decorated in M2000.
Function ccode {
long primes(long a[], long b)
{
@@ -52,53 +52,54 @@ Module checkit {
return 0;
}
}
- \\ extract code. &functionname() is a string with the code inside "{ }"
- \\ a reference to function actual is code of function in m2000
- \\ using Document object we have an easy way to drop paragraphs
+ ' extract code. &functionname() is a string with the code inside "{ }"
+ ' a reference to function actual is code of function in m2000
+ ' using Document object we have an easy way to drop paragraphs
document code$=Mid$(&ccode(), 2, len(&ccode())-2)
- \\ remove 1st line two times \\ one line for an edit information from interpreter
- \\ paragraph$(code$, 1) export paragraph 1st,using third parameter -1 means delete after export.
+ ' remove 1st line two times ' one line for an edit information from interpreter
+ ' paragraph$(code$, 1) export paragraph 1st,using third parameter -1 means delete after export.
drop$=paragraph$(code$,1,-1)+paragraph$(code$,1,-1)
If DisplayOnce Else {
+ If exist(temporary$+"MyName.dll") then dos "del "+temporary$+"MyName.*", 200;
Report 2, "c code for primes"
- Report code$ \\ report stop after 3/4 of screen lines use. Press spacebar or mouse button to continue
+ Report code$ ' report stop after 3/4 of screen lines use. Press spacebar or mouse button to continue
DisplayOnce++
}
- \\ dos "del c:\MyName.*", 200;
- If not exist("c:\MyName.dll") then {
+
+ If not exist(temporary$+"MyName.dll") then {
Report 2, "Now we have to make a dll"
- Rem : Load Make \\ we can use a Make.gsb in current folder - this is the user folder for now
+ Rem : Load Make ' we can use a Make.gsb in current folder - this is the user folder for now
Module MAKE ( fname$, code$, timeout ) {
if timeout<1000 then timeout=1000
If left$(fname$,2)="My" Else Error "Not proper name - use 'My' as first two letters"
Print "Delete old files"
- try { remove "c:\MyName" }
- Dos "del c:\"+fname$+".*", timeout;
+ try { remove temporary$+"MyName" }
+ Dos "del "+temporary$+fname$+".*", timeout;
Print "Save c file"
- Open "c:\"+fname$+".c" for output as F \\ use of non unicode output
+ Open temporary$+fname$+".c" for output as F ' use of non unicode output
Print #F, code$
Close #F
- \\ use these two lines for opening dos console and return to M2000 command line
- rem : Dos "cd c:\ && gcc -c -DBUILD_DLL "+fname$+".c"
+ ' use these two lines for opening dos console and return to M2000 command line
+ rem : Dos "cd " +temporary$+" && gcc -c -DBUILD_DLL "+fname$+".c"
rem : Error "Check for errors"
- \\ by default we give a time to process dos command and then continue
+ ' by default we give a time to process dos command and then continue
Print "make object file"
- dos "cd c:\ && gcc -c -DBUILD_DLL "+fname$+".c" , timeout;
- if exist("c:\"+fname$+".o") then {
+ dos "cd " +temporary$+" && gcc -c -DBUILD_DLL "+fname$+".c" , timeout;
+ if exist(temporary$+fname$+".o") then {
Print "make dll"
- dos "cd c:\ && gcc -shared -o "+fname$+".dll "+fname$+".o -Wl,--out-implib,libmessage.a", timeout;
+ dos "cd " +temporary$+" && gcc -shared -o "+fname$+".dll "+fname$+".o -Wl,--out-implib,libmessage.a", timeout;
} else Error "No object file - Error"
- if not exist("c:\"+fname$+".dll") then Error "No dll - Error"
+ if not exist(temporary$+fname$+".dll") then Error "No dll - Error"
}
Make "MyName", code$, 1000
}
- Declare primes lib c "c:\MyName.primes" {long c, long d} \\ c after lib mean CDecl call
- \\ So now we can check error
- \\ make a Buffer (add two more longs for any purpose)
- Buffer Clear A as Long*(N+2) \\ so A(0) is base address, of an array of 100002 long (unsign for M2000).
- \\ profiler enable a timecount
+ Declare primes lib c temporary$+"MyName.primes" {long c, long d} ' c after lib mean CDecl call
+ ' So now we can check error
+ ' make a Buffer (add two more longs for any purpose)
+ Buffer Clear A as Long*(N+2) ' so A(0) is base address, of an array of 100002 long (unsign for M2000).
+ ' profiler enable a timecount
profiler
Call primes(A(0), N)
m=timecount
@@ -118,7 +119,8 @@ Module checkit {
Print
}
Print format$("Compute {0} primes in range 1 to {1}, in msec:{2:3}", total, N, m)
- \\ unload dll, we have to use exactly the same name, as we use it in declare except for last chars ".dll"
- remove "c:\MyName"
+ ' unload dll, we have to use exactly the same name, as we use it in declare except for last chars ".dll"
+ remove temporary$+"MyName"
}
+' use clear statement to clear static variables before run this, to make new dll
checkit
diff --git a/Task/Call-a-function/Langur/call-a-function-6.langur b/Task/Call-a-function/Langur/call-a-function-6.langur
index 1efc364d84..846df84db9 100644
--- a/Task/Call-a-function/Langur/call-a-function-6.langur
+++ b/Task/Call-a-function/Langur/call-a-function-6.langur
@@ -1 +1 @@
-mapX(amb, wordsets...)
+testfn(a, b, wordsets...)
diff --git a/Task/Call-an-object-method/BQN/call-an-object-method.bqn b/Task/Call-an-object-method/BQN/call-an-object-method.bqn
new file mode 100644
index 0000000000..eb5f410f28
--- /dev/null
+++ b/Task/Call-an-object-method/BQN/call-an-object-method.bqn
@@ -0,0 +1,7 @@
+foo ← {
+ Spam ⇐ {𝕊: "Wonderful Spam!!!"}
+ Eggs ⇐ {𝕨+𝕩}
+}
+
+•Show 1 foo.Eggs 2
+ foo.Spam@
diff --git a/Task/Canonicalize-CIDR/EasyLang/canonicalize-cidr.easy b/Task/Canonicalize-CIDR/EasyLang/canonicalize-cidr.easy
index 64d7aae038..7c1c9054e8 100644
--- a/Task/Canonicalize-CIDR/EasyLang/canonicalize-cidr.easy
+++ b/Task/Canonicalize-CIDR/EasyLang/canonicalize-cidr.easy
@@ -1,23 +1,15 @@
func$ can_cidr s$ .
- n[] = number strsplit s$ "./"
- if len n[] <> 5
- return ""
- .
+ n[] = number strtok s$ "./"
+ if len n[] <> 5 : return ""
for i to 4
- if n[i] < 0 or n[i] > 255
- return ""
- .
+ if n[i] < 0 or n[i] > 255 : return ""
ad = ad * 256 + n[i]
.
- if n[5] > 31 or n[5] < 1
- return ""
- .
+ if n[5] > 31 or n[5] < 1 : return ""
mask = bitnot (bitshift 1 (32 - n[5]) - 1)
ad = bitand ad mask
for i to 4
- if r$ <> ""
- r$ = "." & r$
- .
+ if r$ <> "" : r$ = "." & r$
r$ = ad mod 256 & r$
ad = ad div 256
.
diff --git a/Task/Canonicalize-CIDR/FreeBASIC/canonicalize-cidr.basic b/Task/Canonicalize-CIDR/FreeBASIC/canonicalize-cidr.basic
index 97b62bc879..bd4af5e919 100644
--- a/Task/Canonicalize-CIDR/FreeBASIC/canonicalize-cidr.basic
+++ b/Task/Canonicalize-CIDR/FreeBASIC/canonicalize-cidr.basic
@@ -1,54 +1,99 @@
-#lang "qb"
+Const MAX_OCTET = 255
+Const MIN_NETWORK = 1
+Const MAX_NETWORK = 32
+Const OCTET_BITS = 8
-REM THE Binary OPS ONLY WORK On SIGNED 16-Bit NUMBERS
-REM SO WE STORE THE IP ADDRESS As AN ARRAY OF FOUR OCTETS
-Cls
-Dim IP(3)
-Do
- REM Read DEMO Data
- 140 Read CI$
- If CI$ = "" Then Exit Do 'Sleep: End
- REM FIND /
- SL = 0
- For I = Len(CI$) To 1 Step -1
- If Mid$(CI$,I,1) = "/" Then SL = I : I = 1
- Next I
- If SL = 0 Then Print "INVALID CIDR STRING: '"; CI$; "'": Goto 140
- NW = Val(Mid$(CI$,SL+1))
- If NW < 1 Or NW > 32 Then Print "INVALID NETWORK WIDTH:"; NW: Goto 140
- REM PARSE OCTETS INTO IP ARRAY
- BY = 0 : N = 0
- For I = 1 To SL-1
- C$ = Mid$(CI$,I,1)
- If Not (C$ <> ".") Then
- IP(N) = BY : N = N + 1
- BY = 0
- If IP(N-1) < 256 Then 310
- Print "INVALID OCTET VALUE:"; IP(N-1): Goto 140
- Else C = Val(C$):If C Or (C$="0") Then BY = BY*10+C
+Type IPAddress
+ octets(3) As Integer
+End Type
+
+Function isDigit(Byval ch As String) As Boolean
+ Return (Asc(ch) >= Asc("0")) And (Asc(ch) <= Asc("9"))
+End Function
+
+Function ParseIPAddress(cidr As String, Byref networkWidth As Integer) As IPAddress
+ Dim As IPAddress ip
+ Dim As Integer slashPos = Instr(cidr, "/")
+ Dim As String ipPart = Left(cidr, slashPos - 1)
+
+ networkWidth = Val(Mid(cidr, slashPos + 1))
+
+ Dim As Integer i, currentOctet = 0, octetValue = 0
+ For i = 1 To Len(ipPart)
+ If Mid(ipPart, i, 1) = "." Then
+ ip.octets(currentOctet) = octetValue
+ currentOctet += 1
+ octetValue = 0
+ Elseif IsDigit(Mid(ipPart, i, 1)) Then
+ octetValue = octetValue * 10 + Val(Mid(ipPart, i, 1))
End If
- 310 '
- Next I
- IP(N) = BY : N = N + 1
- If IP(N-1) > 255 Then Print "INVALID OCTET VALUE:"; IP(N-1): Goto 140
- REM NUMBER OF COMPLETE OCTETS IN NETWORK PART
- NB = Int(NW/8)
- REM NUMBER OF NETWORK BITS IN PARTIAL OCTET
- XB = NW And 7
- REM ZERO Out HOST BITS IN PARTIAL OCTET
- IP(NB) = IP(NB) And (255 - 2^(8-XB) + 1)
- REM And SET Any ALL-HOST OCTETS To 0
- If NB < 3 Then For I = NB +1 To 3 : IP(I) = 0 : Next I
- REM Print Out THE RESULT
- Print Mid$(Str$(IP(0)),2);
- For I = 1 To 3
- Print "."; Mid$(Str$(IP( I)),2);
- Next I
- Print Mid$(CI$,SL)
-Loop
-Data "87.70.141.1/22", "36.18.154.103/12", "62.62.197.11/29"
-Data "67.137.119.181/4", "161.214.74.21/24", "184.232.176.184/18"
-REM SOME INVALID INPUTS
-Data "127.0.0.1", "123.45.67.89/0", "98.76.54.32/100", "123.456.789.0/12"
+ Next
+ ip.octets(currentOctet) = octetValue
+
+ Return ip
+End Function
+
+Function ApplyNetworkMask(ip As IPAddress, networkWidth As Integer) As IPAddress
+ Dim As IPAddress result = ip
+ Dim As Integer completeOctets = networkWidth \ OCTET_BITS
+ Dim As Integer remainingBits = networkWidth And 7
+
+ ' Apply mask to partial octet
+ If completeOctets < 4 Then
+ result.octets(completeOctets) And= (MAX_OCTET - 2^(OCTET_BITS-remainingBits) + 1)
+ ' Zero remaining octets
+ For i As Integer = completeOctets + 1 To 3
+ result.octets(i) = 0
+ Next
+ End If
+
+ Return result
+End Function
+
+Function ValidateInput(ip As IPAddress, networkWidth As Integer, cidr As String) As Boolean
+ If Instr(cidr, "/") = 0 Then
+ Print "INVALID CIDR STRING: '"; cidr; "'"
+ Return False
+ End If
+
+ If networkWidth < MIN_NETWORK Or networkWidth > MAX_NETWORK Then
+ Print "INVALID NETWORK WIDTH:"; networkWidth
+ Return False
+ End If
+
+ For i As Integer = 0 To 3
+ If ip.octets(i) > MAX_OCTET Then
+ Print "INVALID OCTET VALUE:"; ip.octets(i)
+ Return False
+ End If
+ Next
+
+ Return True
+End Function
+
+Sub ProcessCIDR(cidr As String)
+ Dim As Integer networkWidth
+ Dim As IPAddress ip = ParseIPAddress(cidr, networkWidth)
+
+ If Not ValidateInput(ip, networkWidth, cidr) Then Exit Sub
+
+ ip = ApplyNetworkMask(ip, networkWidth)
+
+ Dim As String result = Str(ip.octets(0))
+ For i As Integer = 1 To 3
+ result &= "." & Str(ip.octets(i))
+ Next
+ Print result & "/" & networkWidth
+End Sub
+
+' Main program
+Dim As String cidr(9) = { _
+"87.70.141.1/22", "36.18.154.103/12", "62.62.197.11/29", _
+"67.137.119.181/4", "161.214.74.21/24", "184.232.176.184/18", _
+"127.0.0.1", "123.45.67.89/0", "98.76.54.32/100", "123.456.789.0/12" }
+
+For i As Integer = 0 To 9
+ ProcessCIDR(cidr(i))
+Next
Sleep
diff --git a/Task/Cantor-set/V-(Vlang)/cantor-set.v b/Task/Cantor-set/V-(Vlang)/cantor-set.v
index 42d284fa1b..4da07c3172 100644
--- a/Task/Cantor-set/V-(Vlang)/cantor-set.v
+++ b/Task/Cantor-set/V-(Vlang)/cantor-set.v
@@ -5,12 +5,10 @@ const (
fn cantor(mut lines [][]u8, start int, len int, index int) {
seg := len / 3
- if seg == 0 {
- return
- }
+ if seg == 0 {return}
for i in index.. height {
for j in start + seg..start + 2 * seg {
- lines[i][j] = ' '[0]
+ lines[i][j] = " " [0]
}
}
cantor(mut lines, start, seg, index + 1)
diff --git a/Task/Cartesian-product-of-two-or-more-lists/Langur/cartesian-product-of-two-or-more-lists.langur b/Task/Cartesian-product-of-two-or-more-lists/Langur/cartesian-product-of-two-or-more-lists.langur
index 88328fabe6..41c5649210 100644
--- a/Task/Cartesian-product-of-two-or-more-lists/Langur/cartesian-product-of-two-or-more-lists.langur
+++ b/Task/Cartesian-product-of-two-or-more-lists/Langur/cartesian-product-of-two-or-more-lists.langur
@@ -1,16 +1,16 @@
val X = fn ...x:x
-writeln mapX(X, [1, 2], [3, 4]) == [[1, 3], [1, 4], [2, 3], [2, 4]]
-writeln mapX(X, [3, 4], [1, 2]) == [[3, 1], [3, 2], [4, 1], [4, 2]]
-writeln mapX(X, [1, 2], []) == []
-writeln mapX(X, [], [1, 2]) == []
+writeln mapX([1, 2], [3, 4], by=X) == [[1, 3], [1, 4], [2, 3], [2, 4]]
+writeln mapX([3, 4], [1, 2], by=X) == [[3, 1], [3, 2], [4, 1], [4, 2]]
+writeln mapX([1, 2], [], by=X) == []
+writeln mapX([], [1, 2], by=X) == []
writeln()
-writeln mapX(X, [1776, 1789], [7, 12], [4, 14, 23], [0, 1])
+writeln mapX([1776, 1789], [7, 12], [4, 14, 23], [0, 1], by=X)
writeln()
-writeln mapX(X, [1, 2, 3], [30], [500, 100])
+writeln mapX([1, 2, 3], [30], [500, 100], by=X)
writeln()
-writeln mapX(X, [1, 2, 3], [], [500, 100])
+writeln mapX([1, 2, 3], [], [500, 100], by=X)
writeln()
diff --git a/Task/Cartesian-product-of-two-or-more-lists/Quackery/cartesian-product-of-two-or-more-lists.quackery b/Task/Cartesian-product-of-two-or-more-lists/Quackery/cartesian-product-of-two-or-more-lists.quackery
index f5d68fb2af..f4e6d266e1 100644
--- a/Task/Cartesian-product-of-two-or-more-lists/Quackery/cartesian-product-of-two-or-more-lists.quackery
+++ b/Task/Cartesian-product-of-two-or-more-lists/Quackery/cartesian-product-of-two-or-more-lists.quackery
@@ -1,13 +1,26 @@
- [ [] unrot
+ [ [] temp put
swap witheach
- [ over witheach
- [ over nested
- swap nested join
- nested dip rot join
- unrot ]
- drop ] drop ] is cartprod ( [ [ --> [ )
+ [ [] temp put
+ over witheach
+ [ dip dup join
+ nested temp gather ]
+ drop temp take
+ temp gather ]
+ drop temp take ] is cart ( [ [ --> [ )
- ' [ 1 2 ] ' [ 3 4 ] cartprod echo cr
- ' [ 3 4 ] ' [ 1 2 ] cartprod echo cr
- ' [ 1 2 ] ' [ ] cartprod echo cr
- ' [ ] ' [ 1 2 ] cartprod echo cr
+ [ behead swap witheach cart ] is n-cart ( [ --> [ )
+
+ ' [ 1 2 ] ' [ 3 4 ] cart echo cr cr
+ ' [ 1 2 ] ' [ ] cart echo cr cr
+ ' [ ] ' [ 1 2 ] cart echo cr cr
+
+ ' [ [ 1776 1789 ] [ 7 12 ] [ 4 14 23 ] [ 0 1 ] ] n-cart
+ say "[ "
+ witheach
+ [ i^ 0 != if [ say " " ]
+ echo
+ i 0 = if [ say " ]" ] cr ]
+ cr
+
+ ' [ [ 1 2 3 ] [ 30 ] [ 500 100 ] ] n-cart echo cr cr
+ ' [ [ 1 2 3 ] [ ] [ 500 100 ] ] n-cart echo cr cr
diff --git a/Task/Case-sensitivity-of-identifiers/GW-BASIC/case-sensitivity-of-identifiers.basic b/Task/Case-sensitivity-of-identifiers/GW-BASIC/case-sensitivity-of-identifiers.basic
deleted file mode 100644
index 33a43f9953..0000000000
--- a/Task/Case-sensitivity-of-identifiers/GW-BASIC/case-sensitivity-of-identifiers.basic
+++ /dev/null
@@ -1,5 +0,0 @@
-10 dog$ = "Benjamin"
-20 dog$ = "Smokey"
-30 dog$ = "Samba"
-40 dog$ = "Bernie"
-50 print "There is just one dog, named ";dog$
diff --git a/Task/Case-sensitivity-of-identifiers/Joy/case-sensitivity-of-identifiers.joy b/Task/Case-sensitivity-of-identifiers/Joy/case-sensitivity-of-identifiers.joy
new file mode 100644
index 0000000000..5e074a15e6
--- /dev/null
+++ b/Task/Case-sensitivity-of-identifiers/Joy/case-sensitivity-of-identifiers.joy
@@ -0,0 +1,17 @@
+DEFINE dog == "Benjamin".
+DEFINE Dog == "Samba".
+DEFINE DOG == "Bernie".
+"The three dogs are named"
+"." DOG "and" Dog "," dog "The three dogs are named"
+.
+"The three dogs are named"
+.
+"Benjamin"
+.
+","
+.
+"Samba"
+.
+"and"
+.
+"Bernie"
diff --git a/Task/Catalan-numbers-Pascals-triangle/FutureBasic/catalan-numbers-pascals-triangle.basic b/Task/Catalan-numbers-Pascals-triangle/FutureBasic/catalan-numbers-pascals-triangle.basic
new file mode 100644
index 0000000000..f8d7a51702
--- /dev/null
+++ b/Task/Catalan-numbers-Pascals-triangle/FutureBasic/catalan-numbers-pascals-triangle.basic
@@ -0,0 +1,20 @@
+ local fn CatalanNumbers( levels as int )
+ int k, n
+ double num, den, cat
+
+ printf @"1"
+
+ for n = 2 to levels
+ num = 1 : den = 1
+ for k = 2 to n
+ num *= ( n + k )
+ den *= k
+ cat = num / den
+ next
+ printf @"%.f", cat
+ next
+end fn
+
+fn CatalanNumbers( 30 )
+
+HandleEvents
diff --git a/Task/Catalan-numbers-Pascals-triangle/PascalABC.NET/catalan-numbers-pascals-triangle.pas b/Task/Catalan-numbers-Pascals-triangle/PascalABC.NET/catalan-numbers-pascals-triangle.pas
new file mode 100644
index 0000000000..f031c01feb
--- /dev/null
+++ b/Task/Catalan-numbers-Pascals-triangle/PascalABC.NET/catalan-numbers-pascals-triangle.pas
@@ -0,0 +1,14 @@
+const
+ n = 15;
+
+begin
+ var t: array[0..n + 1] of integer;
+ t[1] := 1;
+ for var i := 1 to n do
+ begin
+ for var j := i downto 1 do t[j] += t[j - 1];
+ t[i + 1] := t[i];
+ for var j := i + 1 downto 1 do t[j] += t[j - 1];
+ print(t[i + 1] - t[i]);
+ end;
+end.
diff --git a/Task/Catalan-numbers/EDSAC-order-code/catalan-numbers.edsac b/Task/Catalan-numbers/EDSAC-order-code/catalan-numbers.edsac
index 2c170a456d..4a49996986 100644
--- a/Task/Catalan-numbers/EDSAC-order-code/catalan-numbers.edsac
+++ b/Task/Catalan-numbers/EDSAC-order-code/catalan-numbers.edsac
@@ -12,9 +12,9 @@
Must be loaded at an even address.
Input: Number is at 0D.]
T 56 K
- GKA3FT42@A47@T31@ADE10@T31@A48@T31@SDTDH44#@NDYFLDT4DS43@TF
- H17@S17@A43@G23@UFS43@T1FV4DAFG50@SFLDUFXFOFFFSFL4FT4DA49@T31@
- A1FA43@G20@XFP1024FP610D@524D!FO46@O26@XFO46@SFL8FT4DE39@
+ GKA3FT42@A47@T31@ADE10@T31@A48@T31@SDTDH44#@NDYFLDT4DS43@TFH17@
+ S17@A43@G23@UFS43@T1FV4DAFG50@SFLDUFXFOFFFSFL4FT4DA49@T31@A1FA43@
+ G20@XFT44#ZPFT43ZP1024FP610D@524D!FO46@O26@XFO46@SFL8FT4DE39@
[Main routine]
T 120 K [load at 120]
diff --git a/Task/Catalan-numbers/Haskell/catalan-numbers-1.hs b/Task/Catalan-numbers/Haskell/catalan-numbers-1.hs
new file mode 100644
index 0000000000..54c01db03f
--- /dev/null
+++ b/Task/Catalan-numbers/Haskell/catalan-numbers-1.hs
@@ -0,0 +1,9 @@
+infixl 7 *.
+(*.) :: Num a => a -> [a] -> [a]
+x *. (p:ps) = x*p : x*.ps
+
+instance Num a => Num [a] where
+ negate = map negate
+ (+) = zipWith (+)
+ (*) (p:ps) (q:qs) = p*q : ((p*.qs) + ps*(q:qs))
+ fromInteger n = fromInteger n:repeat 0
diff --git a/Task/Catalan-numbers/Haskell/catalan-numbers-2.hs b/Task/Catalan-numbers/Haskell/catalan-numbers-2.hs
new file mode 100644
index 0000000000..59351ad478
--- /dev/null
+++ b/Task/Catalan-numbers/Haskell/catalan-numbers-2.hs
@@ -0,0 +1,2 @@
+catalan :: [Integer]
+catalan = 1 : catalan^2
diff --git a/Task/Catalan-numbers/Haskell/catalan-numbers-3.hs b/Task/Catalan-numbers/Haskell/catalan-numbers-3.hs
new file mode 100644
index 0000000000..ef200970ea
--- /dev/null
+++ b/Task/Catalan-numbers/Haskell/catalan-numbers-3.hs
@@ -0,0 +1,2 @@
+ghci> take 15 catalan
+[1,1,2,5,14,42,132,429,1430,4862,16796,58786,208012,742900,2674440]
diff --git a/Task/Catalan-numbers/Haskell/catalan-numbers.hs b/Task/Catalan-numbers/Haskell/catalan-numbers-4.hs
similarity index 100%
rename from Task/Catalan-numbers/Haskell/catalan-numbers.hs
rename to Task/Catalan-numbers/Haskell/catalan-numbers-4.hs
diff --git a/Task/Catalan-numbers/Langur/catalan-numbers.langur b/Task/Catalan-numbers/Langur/catalan-numbers.langur
index 81d8b2e82f..51ff6b65a4 100644
--- a/Task/Catalan-numbers/Langur/catalan-numbers.langur
+++ b/Task/Catalan-numbers/Langur/catalan-numbers.langur
@@ -1,4 +1,4 @@
-val factorial = fn x:if(x < 2: 1; x * self(x - 1))
+val factorial = fn x:if(x < 2: 1; x * fn((x - 1)))
val catalan = fn n:factorial(2 * n) / factorial(n+1) / factorial(n)
diff --git a/Task/Catamorphism/Lua/catamorphism.lua b/Task/Catamorphism/Lua/catamorphism-1.lua
similarity index 100%
rename from Task/Catamorphism/Lua/catamorphism.lua
rename to Task/Catamorphism/Lua/catamorphism-1.lua
diff --git a/Task/Catamorphism/Lua/catamorphism-2.lua b/Task/Catamorphism/Lua/catamorphism-2.lua
new file mode 100644
index 0000000000..29a7baf0fa
--- /dev/null
+++ b/Task/Catamorphism/Lua/catamorphism-2.lua
@@ -0,0 +1,19 @@
+function foldl(func, init, array)
+ assert(type(func) == "function", "type(fn) == " .. type(func))
+ assert(type(array) == "table", "type(array) == " .. type(array))
+ local result = init
+ for v in ipairs(array) do
+ result = func(result, v)
+ end
+ return result
+end
+
+function add(x, y) return x + y end
+mul = function(x, y) return x * y end
+
+nums = {1,2,3,4,5,6,7,8,9}
+print("add 1 to 9 ", foldl(add, 0, nums))
+print("multiply", foldl(mul, 1, nums))
+-- uses anonymous function
+print("concatenate",
+ foldl(function(x,y) return x .. y end, "", nums))
diff --git a/Task/Catamorphism/Pascal/catamorphism.pas b/Task/Catamorphism/Pascal/catamorphism.pas
index ad363522b6..e17cca17ba 100644
--- a/Task/Catamorphism/Pascal/catamorphism.pas
+++ b/Task/Catamorphism/Pascal/catamorphism.pas
@@ -1,53 +1,38 @@
program reduceApp;
+{$modeswitch classicProcVars+}
+
+{Works in many modes with Free Pascal Compiler:
+fpc, objfpc, delphi, macpas, iso, extendedpascal}
+
type
-// tmyArray = array of LongInt;
- tmyArray = array[-5..5] of LongInt;
- tmyFunc = function (a,b:LongInt):LongInt;
+ Num = LongInt; // this can be changed to Real if desired
+ BinaryFunc = function(a, b: Num): Num;
-function add(x,y:LongInt):LongInt;
-begin
- add := x+y;
-end;
+function add(x, y: Num): Num; begin add := x + y; end;
+function sub(x, y: Num): Num; begin sub := x - y; end;
+function mul(x, y: Num): Num; begin mul := x * y; end;
-function sub(k,l:LongInt):LongInt;
-begin
- sub := k-l;
-end;
-
-function mul(r,t:LongInt):LongInt;
-begin
- mul := r*t;
-end;
-
-function reduce(myFunc:tmyFunc;a:tmyArray):LongInt;
+function reduce(func: BinaryFunc; a: array of Num): Num;
var
- i,res : LongInt;
+ i: Integer;
+ answer: Num;
begin
- res := a[low(a)];
- For i := low(a)+1 to high(a) do
- res := myFunc(res,a[i]);
- reduce := res;
+ answer := a[low(a)];
+ for i := low(a)+1 to high(a) do
+ answer := func(answer, a[i]);
+ reduce := answer; // return answer
end;
-procedure InitMyArray(var a:tmyArray);
-var
- i: LongInt;
-begin
- For i := low(a) to high(a) do
- begin
- //no a[i] = 0
- a[i] := i + ord(i=0);
- write(a[i],',');
- end;
- writeln(#8#32);
-end;
-
-var
- ma : tmyArray;
+VAR
+ // dynamic array
+ ma: array of Num;
+ // static arrays
+ mb: array[1..9] of Num = (1,2,3,4,5,6,7,8,9);
+ mc: array[0..8] of Num = (1,2,3,4,5,6,7,8,9);
BEGIN
- InitMyArray(ma);
- writeln(reduce(@add,ma));
- writeln(reduce(@sub,ma));
- writeln(reduce(@mul,ma));
+ ma := [1,2,3,4,5,6,7,8,9];
+ writeln(reduce(add, ma));
+ writeln(reduce(sub, mb));
+ writeln(reduce(mul, mc));
END.
diff --git a/Task/Chaocipher/EasyLang/chaocipher.easy b/Task/Chaocipher/EasyLang/chaocipher.easy
index f748565f29..3d9af716be 100644
--- a/Task/Chaocipher/EasyLang/chaocipher.easy
+++ b/Task/Chaocipher/EasyLang/chaocipher.easy
@@ -1,8 +1,6 @@
proc index c$ . a$[] ind .
for ind = 1 to len a$[]
- if a$[ind] = c$
- return
- .
+ if a$[ind] = c$ : return
.
ind = 0
.
@@ -14,12 +12,9 @@ func$ chao txt$ mode .
right$[] = strchars right$
len tmp$[] 26
for c$ in strchars txt$
- # print strjoin left$[] & " " & strjoin right$[]
if mode = 1
index c$ right$[] ind
- if ind = 0
- return ""
- .
+ if ind = 0 : return ""
r$ &= left$[ind]
else
index c$ left$[] ind
diff --git a/Task/Chaocipher/Fortran/chaocipher.f b/Task/Chaocipher/Fortran/chaocipher.f
new file mode 100644
index 0000000000..ef2f081da9
--- /dev/null
+++ b/Task/Chaocipher/Fortran/chaocipher.f
@@ -0,0 +1,190 @@
+!
+!This program implements the **Chaocipher encryption algorithm** in FORTRAN, extended to handle all printable ASCII characters (32-127).
+! The Chaocipher is a polyalphabetic cipher invented by John F. Byrne in 1918, which dynamically permutes two alphabets after
+! processing each character, making it highly secure and resistant to cryptanalysis.
+!
+!#### Key Features:
+!1. **Initialization**:
+! - Two alphabets (`left` and `right`) are initialized with shuffled ASCII characters (32-127).
+! - The `plaintext` is set to "WELLDONEISBETTERTHANWELLSAID".
+!
+!2. **Enciphering**:
+! - For each character in the plaintext:
+! - Locate the character in the `right` alphabet.
+! - Find the corresponding ciphertext character in the `left` alphabet.
+! - Permute both alphabets based on the Chaocipher rules:
+! - The `left` alphabet is rotated to bring the ciphertext character to the top, and a specific character is moved to a new position.
+! - The `right` alphabet is similarly rotated, with an additional rotation step.
+!
+!3. **Deciphering**:
+! - The ciphertext is decrypted back into plaintext using the reverse process:
+! - Locate the ciphertext character in the `left` alphabet.
+! - Find the corresponding plaintext character in the `right` alphabet.
+! - Permute both alphabets identically as in enciphering.
+!
+!4. **Verification**:
+! - After enciphering and deciphering, the program compares the original plaintext with the decrypted text to ensure correctness.
+!
+!#### Output:
+!The program prints:
+!- Initial left and right alphabets.
+!- Enciphered ciphertext.
+!- Deciphered plaintext.
+!- A success message if decryption matches the original plaintext.
+!
+!#### Example Execution:
+!For input plaintext "WELLDONEISBETTERTHANWELLSAID", the program outputs:
+!- Ciphertext: `OAHQHCNYNXTSZJRRHJBYHQKSOUJY`
+!- Decrypted Text: `WELLDONEISBETTERTHANWELLSAID`
+!- Verification: "Decryption successful: plaintext matches decrypted text."
+!
+!This implementation demonstrates both encryption and decryption processes while adhering to Chaocipher's dynamic permutation rules,
+!extended for modern ASCII characters.
+!
+!
+PROGRAM Chaocipher
+ IMPLICIT NONE
+ CHARACTER(LEN=96) :: left, right, left_orig, right_orig
+ CHARACTER(LEN=1000) :: plaintext, ciphertext, decrypted
+ INTEGER :: i, len, ascii_start
+ LOGICAL :: trace
+
+ ! Initialize alphabets and input
+ CALL initialize_alphabets(left, right)
+ left_orig = left
+ right_orig = right
+ plaintext = 'Well, when I was in Egypt, I had a conversation with the Sphinx! She taught me how to sew.'
+ ciphertext = ''
+ decrypted = ''
+ trace = .FALSE.
+ ascii_start = 32 ! ASCII start at space character
+
+ len = LEN_TRIM(plaintext)
+
+ PRINT *, 'Initial Left: ', left
+ PRINT *, 'Initial Right:', right
+ PRINT *, 'Plaintext: ', TRIM(plaintext)
+
+ ! Encipher
+ DO i = 1, len
+ CALL encipher(plaintext(i:i), ciphertext(i:i), left, right, ascii_start)
+ IF (trace) THEN
+ PRINT *, 'Step ', i
+ PRINT *, 'Left: ', left
+ PRINT *, 'Right: ', right
+ END IF
+ END DO
+
+ PRINT *, 'Ciphertext: ', TRIM(ciphertext)
+
+ ! Reset alphabets for deciphering
+ left = left_orig
+ right = right_orig
+
+ ! Decipher
+ DO i = 1, len
+ CALL decipher(ciphertext(i:i), decrypted(i:i), left, right, ascii_start)
+ END DO
+
+ PRINT *, 'Decrypted: ', TRIM(decrypted)
+
+ ! Check for correctness
+ IF (plaintext == decrypted) THEN
+ PRINT *, 'Decryption successful: plaintext matches decrypted text'
+ ELSE
+ PRINT *, 'Decryption failed: plaintext does not match decrypted text'
+ END IF
+
+CONTAINS
+
+ SUBROUTINE initialize_alphabets(left, right)
+ CHARACTER(LEN=96), INTENT(OUT) :: left, right
+ INTEGER :: i, j
+ CHARACTER :: temp
+ REAL :: r
+
+ ! Initialize alphabets with ASCII characters 32-127
+ DO i = 1, 96
+ left(i:i) = CHAR(i + 31)
+ right(i:i) = CHAR(i + 31)
+ END DO
+
+ ! Fisher-Yates shuffle for left alphabet
+ DO i = 96, 2, -1
+ CALL RANDOM_NUMBER(r)
+ j = 1 + FLOOR(i * r)
+ temp = left(i:i)
+ left(i:i) = left(j:j)
+ left(j:j) = temp
+ END DO
+
+ ! Fisher-Yates shuffle for right alphabet
+ DO i = 96, 2, -1
+ CALL RANDOM_NUMBER(r)
+ j = 1 + FLOOR(i * r)
+ temp = right(i:i)
+ right(i:i) = right(j:j)
+ right(j:j) = temp
+ END DO
+END SUBROUTINE initialize_alphabets
+
+ SUBROUTINE encipher(p, c, left, right, ascii_start)
+ CHARACTER(LEN=1), INTENT(IN) :: p
+ CHARACTER(LEN=1), INTENT(OUT) :: c
+ CHARACTER(LEN=96), INTENT(INOUT) :: left, right
+ INTEGER, INTENT(IN) :: ascii_start
+ INTEGER :: pos
+
+ pos = INDEX(right, p)
+ c = left(pos:pos)
+
+ CALL permute_left(left, c, ascii_start)
+ CALL permute_right(right, p, ascii_start)
+ END SUBROUTINE encipher
+
+ SUBROUTINE decipher(c, p, left, right, ascii_start)
+ CHARACTER(LEN=1), INTENT(IN) :: c
+ CHARACTER(LEN=1), INTENT(OUT) :: p
+ CHARACTER(LEN=96), INTENT(INOUT) :: left, right
+ INTEGER, INTENT(IN) :: ascii_start
+ INTEGER :: pos
+
+ pos = INDEX(left, c)
+ p = right(pos:pos)
+
+ CALL permute_left(left, c, ascii_start)
+ CALL permute_right(right, p, ascii_start)
+ END SUBROUTINE decipher
+
+ SUBROUTINE permute_left(alphabet, pivot, ascii_start)
+ CHARACTER(LEN=96), INTENT(INOUT) :: alphabet
+ CHARACTER(LEN=1), INTENT(IN) :: pivot
+ INTEGER, INTENT(IN) :: ascii_start
+ INTEGER :: pos
+ CHARACTER(LEN=1) :: temp
+
+ pos = INDEX(alphabet, pivot)
+ alphabet = alphabet(pos:) // alphabet(:pos-1)
+
+ temp = alphabet(2:2)
+ alphabet(2:49) = alphabet(3:50)
+ alphabet(50:50) = temp
+ END SUBROUTINE permute_left
+
+ SUBROUTINE permute_right(alphabet, pivot, ascii_start)
+ CHARACTER(LEN=96), INTENT(INOUT) :: alphabet
+ CHARACTER(LEN=1), INTENT(IN) :: pivot
+ INTEGER, INTENT(IN) :: ascii_start
+ INTEGER :: pos
+ CHARACTER(LEN=1) :: temp
+
+ pos = INDEX(alphabet, pivot)
+ alphabet = alphabet(pos:) // alphabet(:pos-1)
+ alphabet = alphabet(2:) // alphabet(1:1)
+
+ temp = alphabet(3:3)
+ alphabet(3:49) = alphabet(4:50)
+ alphabet(50:50) = temp
+ END SUBROUTINE permute_right
+
+END PROGRAM Chaocipher
diff --git a/Task/Chaos-game/Ada/chaos-game.ada b/Task/Chaos-game/Ada/chaos-game.ada
new file mode 100644
index 0000000000..fe213c85fc
--- /dev/null
+++ b/Task/Chaos-game/Ada/chaos-game.ada
@@ -0,0 +1,45 @@
+pragma Ada_2022;
+with Ada.Numerics; use Ada.Numerics;
+with Ada.Numerics.Discrete_Random;
+with Ada.Numerics.Elementary_Functions; use Ada.Numerics.Elementary_Functions;
+with Easy_Graphics; use Easy_Graphics;
+
+procedure Chaos_Game is
+ Img : Easy_Image := New_Image ((1, 1), (512, 512), WHITE);
+
+ procedure Chaos (Image : in out Easy_Image;
+ Vertex_Count : Positive;
+ Radius : Float;
+ Iters : Positive) is
+ type Vertex_Array is array (1 .. Vertex_Count) of Point;
+ Vertices : Vertex_Array;
+ subtype Vertex_Range is Integer range 1 .. Vertex_Count;
+ package Rand_V is new Ada.Numerics.Discrete_Random (Vertex_Range);
+ use Rand_V;
+ Gen : Generator;
+ Half_X : constant Integer := X_Last (Image) / 2;
+ Half_Y : constant Integer := Y_Last (Image) / 2;
+ Half_Pi : constant Float := Float (Pi) / 2.0;
+ Two_Pi : constant Float := Float (Pi) * 2.0;
+ V : Integer;
+ X : Integer := Half_X;
+ Y : Integer := Half_Y;
+ begin
+ for V in 1 .. Vertex_Count loop
+ Vertices (V).X := Half_X + Integer (Float (Half_X) *
+ Cos (Half_Pi + (Float (V - 1)) * Two_Pi / Float (Vertex_Count)));
+ Vertices (V).Y := Half_Y - Integer (Float (Half_Y) *
+ Sin (Half_Pi + (Float (V - 1)) * Two_Pi / Float (Vertex_Count)));
+ end loop;
+ for I in 1 .. Iters loop
+ V := Random (Gen);
+ X := X + Integer (Radius * Float (Vertices (V).X - X));
+ Y := Y + Integer (Radius * Float (Vertices (V).Y - Y));
+ Plot (Image, (X, Y), BLACK);
+ end loop;
+ end Chaos;
+
+begin
+ Chaos (Img, 3, 0.5, 250_000);
+ Write_GIF (Img, "chaos_game.gif");
+end Chaos_Game;
diff --git a/Task/Chaos-game/AmigaBASIC/chaos-game.basic b/Task/Chaos-game/AmigaBASIC/chaos-game.basic
new file mode 100644
index 0000000000..637e89a1da
--- /dev/null
+++ b/Task/Chaos-game/AmigaBASIC/chaos-game.basic
@@ -0,0 +1,28 @@
+DEFINT a-z
+w=600:h=180:w2=300
+x=w*RND:y=h*RND
+
+FOR i=1 TO 32000
+ v=2*RND+1
+ ON v GOTO One, Two, Three
+
+One:
+ x=x/2
+ y=y/2
+ GOTO Draw
+
+Two:
+ x=w2+(w2-x)/2
+ y=h-(h-y)/2
+ GOTO Draw
+
+Three:
+ x=w-(w-x)/2
+ y=y/2
+
+Draw:
+ PSET (x,y),v
+NEXT
+
+loop:
+ GOTO loop
diff --git a/Task/Chaos-game/Atari-BASIC/chaos-game.basic b/Task/Chaos-game/Atari-BASIC/chaos-game.basic
new file mode 100644
index 0000000000..b612f7a348
--- /dev/null
+++ b/Task/Chaos-game/Atari-BASIC/chaos-game.basic
@@ -0,0 +1,18 @@
+10 GRAPHICS 7+16
+20 W=159:H=95:W2=79
+30 X=INT(W*RND(0))
+40 Y=INT(H*RND(0))
+50 FOR I=1 TO 5000
+60 V=INT(3*RND(0))+1
+70 GOTO 100*V
+100 X=X/2:Y=Y/2
+110 GOTO 500
+200 X=W2+(W2-X)/2
+210 Y=H-(H-Y)/2
+220 GOTO 500
+300 X=W-(W-X)/2
+310 Y=Y/2
+500 COLOR V
+510 PLOT X,Y
+520 NEXT I
+530 GOTO 530
diff --git a/Task/Character-codes/Dart/character-codes.dart b/Task/Character-codes/Dart/character-codes.dart
new file mode 100644
index 0000000000..b1b602f4bd
--- /dev/null
+++ b/Task/Character-codes/Dart/character-codes.dart
@@ -0,0 +1,6 @@
+void main() {
+ const string = 'D';
+ print(string.runes.first);
+ var out = String.fromCharCode(67);
+ print(out);
+}
diff --git a/Task/Character-codes/Langur/character-codes.langur b/Task/Character-codes/Langur/character-codes.langur
index e24d7430fe..053f7ab322 100644
--- a/Task/Character-codes/Langur/character-codes.langur
+++ b/Task/Character-codes/Langur/character-codes.langur
@@ -1,11 +1,11 @@
val a1 = 'a'
val a2 = 97
val a3 = "a"[1]
-val a4 = s2cp("a", 1)
+val a4 = s2cp("a", of=1)
val a5 = [a1, a2, a3, a4]
writeln a1 == a2
writeln a2 == a3
writeln a3 == a4
-writeln "numbers: ", join(", ", map(string, [a1, a2, a3, a4, a5]))
-writeln "letters: ", join(", ", map(cp2s, [a1, a2, a3, a4, a5]))
+writeln "numbers: ", join(map([a1, a2, a3, a4, a5], by=string), by=", ")
+writeln "letters: ", join(map([a1, a2, a3, a4, a5], by=cp2s), by=", ")
diff --git a/Task/Check-output-device-is-a-terminal/Wren/check-output-device-is-a-terminal-1.wren b/Task/Check-output-device-is-a-terminal/Wren/check-output-device-is-a-terminal-1.wren
deleted file mode 100644
index 34bcd3db89..0000000000
--- a/Task/Check-output-device-is-a-terminal/Wren/check-output-device-is-a-terminal-1.wren
+++ /dev/null
@@ -1,7 +0,0 @@
-/* Check_output_device_is_a_terminal.wren */
-
-class C {
- foreign static isOutputDeviceTerminal
-}
-
-System.print("Output device is a terminal = %(C.isOutputDeviceTerminal)")
diff --git a/Task/Check-output-device-is-a-terminal/Wren/check-output-device-is-a-terminal-2.wren b/Task/Check-output-device-is-a-terminal/Wren/check-output-device-is-a-terminal-2.wren
deleted file mode 100644
index a1e31b0511..0000000000
--- a/Task/Check-output-device-is-a-terminal/Wren/check-output-device-is-a-terminal-2.wren
+++ /dev/null
@@ -1,82 +0,0 @@
-#include
-#include
-#include
-#include
-#include "wren.h"
-
-void C_isOutputDeviceTerminal(WrenVM* vm) {
- bool isTerminal = (bool)isatty(fileno(stdout));
- wrenSetSlotBool(vm, 0, isTerminal);
-}
-
-WrenForeignMethodFn bindForeignMethod(
- WrenVM* vm,
- const char* module,
- const char* className,
- bool isStatic,
- const char* signature) {
- if (strcmp(module, "main") == 0) {
- if (strcmp(className, "C") == 0) {
- if (isStatic && strcmp(signature, "isOutputDeviceTerminal") == 0) {
- return C_isOutputDeviceTerminal;
- }
- }
- }
- return NULL;
-}
-
-static void writeFn(WrenVM* vm, const char* text) {
- printf("%s", text);
-}
-
-void errorFn(WrenVM* vm, WrenErrorType errorType, const char* module, const int line, const char* msg) {
- switch (errorType) {
- case WREN_ERROR_COMPILE:
- printf("[%s line %d] [Error] %s\n", module, line, msg);
- break;
- case WREN_ERROR_STACK_TRACE:
- printf("[%s line %d] in %s\n", module, line, msg);
- break;
- case WREN_ERROR_RUNTIME:
- printf("[Runtime Error] %s\n", msg);
- break;
- }
-}
-
-char *readFile(const char *fileName) {
- FILE *f = fopen(fileName, "r");
- fseek(f, 0, SEEK_END);
- long fsize = ftell(f);
- rewind(f);
- char *script = malloc(fsize + 1);
- fread(script, 1, fsize, f);
- fclose(f);
- script[fsize] = 0;
- return script;
-}
-
-int main() {
- WrenConfiguration config;
- wrenInitConfiguration(&config);
- config.writeFn = &writeFn;
- config.errorFn = &errorFn;
- config.bindForeignMethodFn = &bindForeignMethod;
- WrenVM* vm = wrenNewVM(&config);
- const char* module = "main";
- const char* fileName = "Check_output_device_is_a_terminal.wren";
- char *script = readFile(fileName);
- WrenInterpretResult result = wrenInterpret(vm, module, script);
- switch (result) {
- case WREN_RESULT_COMPILE_ERROR:
- printf("Compile Error!\n");
- break;
- case WREN_RESULT_RUNTIME_ERROR:
- printf("Runtime Error!\n");
- break;
- case WREN_RESULT_SUCCESS:
- break;
- }
- wrenFreeVM(vm);
- free(script);
- return 0;
-}
diff --git a/Task/Check-output-device-is-a-terminal/Wren/check-output-device-is-a-terminal.wren b/Task/Check-output-device-is-a-terminal/Wren/check-output-device-is-a-terminal.wren
new file mode 100644
index 0000000000..e8da13ba3c
--- /dev/null
+++ b/Task/Check-output-device-is-a-terminal/Wren/check-output-device-is-a-terminal.wren
@@ -0,0 +1,5 @@
+import "io" for Stdout, Stderr
+
+System.print("Is output device a terminal?")
+System.print(" stdout: %(Stdout.isTerminal)")
+System.print(" stderr: %(Stderr.isTerminal)")
diff --git a/Task/Check-that-file-exists/Langur/check-that-file-exists.langur b/Task/Check-that-file-exists/Langur/check-that-file-exists.langur
index a275544023..b6ce97188b 100644
--- a/Task/Check-that-file-exists/Langur/check-that-file-exists.langur
+++ b/Task/Check-that-file-exists/Langur/check-that-file-exists.langur
@@ -1,4 +1,4 @@
-val printresult = impure fn(file) {
+val printresult = fn*(file) {
write file, ": "
if val p = prop(file) {
if p'isdir {
diff --git a/Task/Chernicks-Carmichael-numbers/ALGOL-68/chernicks-carmichael-numbers.alg b/Task/Chernicks-Carmichael-numbers/ALGOL-68/chernicks-carmichael-numbers.alg
new file mode 100644
index 0000000000..df8b4ad05f
--- /dev/null
+++ b/Task/Chernicks-Carmichael-numbers/ALGOL-68/chernicks-carmichael-numbers.alg
@@ -0,0 +1,51 @@
+BEGIN # find some of Chernick's Carmichael numbers - translation of Go #
+
+ PR precision 80 PR # set the precision of LONG LONG INT #
+ PR read "primes.incl.a68" PR # include prime utilities #
+
+ # integer mode large enough to hold a Chernick's Carmichael number #
+ MODE CHERNICKINTEGER = LONG LONG INT;
+ # integer mode large to hold a factor of a Chernick's Carmichael number #
+ MODE CHERNICKFACTOR = LONG INT;
+
+ # returns the value of the Chernick's Carmichaal number U( n, m ) #
+ # or 0 if n and m are not a Chernicj's Carmichael number #
+ PROC possible chernick = ( INT n, m )CHERNICKINTEGER:
+ IF CHERNICKINTEGER prod := 6 * m + 1;
+ NOT is probably prime( prod )
+ THEN 0
+ ELIF CHERNICKFACTOR f := 12 * m + 1;
+ NOT is probably prime( f )
+ THEN 0
+ ELSE CHERNICKFACTOR t := 9 * m;
+ prod *:= f;
+ f := t;
+ BOOL result := TRUE;
+ CHERNICKINTEGER ii := 1;
+ WHILE IF ii > n - 2
+ THEN FALSE
+ ELSE f := ( t +:= t ) + 1;
+ result := is probably prime( f )
+ FI
+ DO ii +:= 1;
+ prod *:= f
+ OD;
+ IF result THEN prod ELSE 0 FI
+ FI # possible chernick # ;
+
+ BEGIN
+ FOR n FROM 3 TO 9 DO
+ INT m := IF n > 4 THEN 2 ^ ( n - 4 ) ELSE 1 FI;
+ WHILE IF CHERNICKINTEGER cn = possible chernick( n, m );
+ cn > 0
+ THEN print( ( "U( ", whole( n, 0 ) ) );
+ print( ( ", " , whole( m, -8 ) ) );
+ print( ( " ): ", whole( cn, 0 ), newline ) );
+ FALSE
+ ELSE m +:= IF n <= 4 THEN 1 ELSE 2 ^ ( n - 4 ) FI;
+ TRUE
+ FI
+ DO SKIP OD
+ OD
+ END
+END
diff --git a/Task/Chinese-zodiac/00-TASK.txt b/Task/Chinese-zodiac/00-TASK.txt
index 5fa4f581b8..04d125ed61 100644
--- a/Task/Chinese-zodiac/00-TASK.txt
+++ b/Task/Chinese-zodiac/00-TASK.txt
@@ -4,11 +4,11 @@ In the Chinese calendar, years are identified using two lists of labels, one of
Years cycle through both lists concurrently, so that both stem and branch advance each year; if we used Roman letters for the stems and numbers for the branches, consecutive years would be labeled A1, B2, C3, etc. Since the two lists are different lengths, they cycle back to their beginning at different points: after J10 we get A11, and then after B12 we get C1. However, since both lists are of even length, only like-parity pairs occur (A1, A3, A5, but not A2, A4, A6), so only half of the 120 possible pairs are included in the sequence. The result is a repeating 60-year pattern within which each name pair occurs only once.
-Mapping the branches to twelve traditional animal deities results in the well-known "Chinese zodiac", assigning each year to a given animal. For example, Saturday, February 10, 2024 CE (in the common Gregorian calendar) began the lunisolar Year of the Dragon.
+Mapping the branches to twelve traditional animal deities results in the well-known "Chinese zodiac", assigning each year to a given animal. For example, Wednesday, January 29, 2025 CE (in the common Gregorian calendar) begins the lunisolar Year of the Snake.
The stems do not have a one-to-one mapping like that of the branches to animals; however, the five pairs of consecutive stems are each associated with one of the traditional wǔxíng elements (Wood, Fire, Earth, Metal, and Water). Further, one of the two years within each element is assigned to yin, the other to yang.
-Thus, the Chinese year beginning in 2024 CE is also the yang year of Wood. Since 12 is an even number, the association between animals and yin/yang aspect doesn't change; consecutive Years of the Dragon will cycle through the five elements, but will always be yang.
+Thus, the Chinese year beginning in 2025 CE is also the yin year of Wood. Since 12 is an even number, the association between animals and yin/yang aspect doesn't change; consecutive Years of the Snake will cycle through the five elements, but will always be yin.
;Task: Create a subroutine or program that will return or output the animal, yin/yang association, and element for the lunisolar year that begins in a given CE year.
@@ -20,10 +20,10 @@ You may optionally provide more information in the form of the year's numerical
* Each element gets two consecutive years; a yang followed by a yin.
* The first year (Wood Rat, yang) of the current 60-year cycle began in 1984 CE.
-The lunisolar year beginning in 2024 CE - which, as already noted, is the year of the Wood Dragon (yang) - is the 41st of the current cycle.
+The lunisolar year beginning in 2025 CE - which, as already noted, is the year of the Wood Snake (yin) - is the 42nd of the current cycle.
;Information for optional task:
* The ten celestial stems are '''甲''' ''jiă'', '''乙''' ''yĭ'', '''丙''' ''bĭng'', '''丁''' ''dīng'', '''戊''' ''wù'', '''己''' ''jĭ'', '''庚''' ''gēng'', '''辛''' ''xīn'', '''壬''' ''rén'', and '''癸''' ''gŭi''. With the ASCII version of Pinyin tones, the names are written "jia3", "yi3", "bing3", "ding1", "wu4", "ji3", "geng1", "xin1", "ren2", and "gui3".
* The twelve terrestrial branches are '''子''' ''zĭ'', '''丑''' ''chŏu'', '''寅''' ''yín'', '''卯''' ''măo'', '''辰''' ''chén'', '''巳''' ''sì'', '''午''' ''wŭ'', '''未''' ''wèi'', '''申''' ''shēn'', '''酉''' ''yŏu'', '''戌''' ''xū'', '''亥''' ''hài''. In ASCII Pinyin, those are "zi3", "chou3", "yin2", "mao3", "chen2", "si4", "wu3", "wei4", "shen1", "you3", "xu1", and "hai4".
-Therefore 1984 was '''甲子''' (''jiă-zĭ'', or jia3-zi3), while 2024 is '''甲辰''' (''jĭa-chén'' or jia3-chen2).
+Therefore 1984 was '''甲子''' (''jiă-zĭ'', or jia3-zi3), while 2025 is '''乙巳''' (''yĭ-sì'' or yi3-si4).
diff --git a/Task/Chowla-numbers/Quackery/chowla-numbers.quackery b/Task/Chowla-numbers/Quackery/chowla-numbers.quackery
new file mode 100644
index 0000000000..6fc47e0c39
--- /dev/null
+++ b/Task/Chowla-numbers/Quackery/chowla-numbers.quackery
@@ -0,0 +1,31 @@
+ [ 2 max
+ dup sqrt+
+ iff 0 else [ dup negate ]
+ unrot
+ times
+ [ dup i^ 1+ /mod
+ 0 = iff
+ [ i^ 1+ +
+ swap dip + ]
+ else drop ]
+ 1+ - ] is chowla ( n --> n )
+
+ 37 times
+ [ say "chowla("
+ i^ 1+ dup echo
+ say ")= "
+ chowla echo cr ]
+ cr
+ ' [ 100 1000 10000 100000 1000000 10000000 ]
+ witheach
+ [ 0 over 2 - times
+ [ i^ 2 + chowla 0 = + ]
+ say "There are " echo
+ say " primes less than "
+ echo cr ]
+ cr
+ 35000000 2 - times
+ [ i^ 2 + dup chowla 1+ = if
+ [ i^ 2 + echo
+ say " is perfect"
+ cr ] ]
diff --git a/Task/Closures-Value-capture/Kotlin/closures-value-capture.kts b/Task/Closures-Value-capture/Kotlin/closures-value-capture-1.kts
similarity index 100%
rename from Task/Closures-Value-capture/Kotlin/closures-value-capture.kts
rename to Task/Closures-Value-capture/Kotlin/closures-value-capture-1.kts
diff --git a/Task/Closures-Value-capture/Kotlin/closures-value-capture-2.kts b/Task/Closures-Value-capture/Kotlin/closures-value-capture-2.kts
new file mode 100644
index 0000000000..03fcbea1ef
--- /dev/null
+++ b/Task/Closures-Value-capture/Kotlin/closures-value-capture-2.kts
@@ -0,0 +1,5 @@
+val results = mutableListOf<() -> Int>()
+for (i in 0..9) {
+ results.add { i * i }
+}
+println(results[3]()) // prints "9"
diff --git a/Task/Closures-Value-capture/Kotlin/closures-value-capture-3.kts b/Task/Closures-Value-capture/Kotlin/closures-value-capture-3.kts
new file mode 100644
index 0000000000..88988eb563
--- /dev/null
+++ b/Task/Closures-Value-capture/Kotlin/closures-value-capture-3.kts
@@ -0,0 +1,2 @@
+val results = (0..9).map { { it * it } }
+println(results[3]()) // prints "9"
diff --git a/Task/Color-of-a-screen-pixel/Atari-BASIC/color-of-a-screen-pixel.basic b/Task/Color-of-a-screen-pixel/Atari-BASIC/color-of-a-screen-pixel.basic
new file mode 100644
index 0000000000..d28e199feb
--- /dev/null
+++ b/Task/Color-of-a-screen-pixel/Atari-BASIC/color-of-a-screen-pixel.basic
@@ -0,0 +1 @@
+LOCATE X,Y,Q
diff --git a/Task/Colorful-numbers/Haskell/colorful-numbers.hs b/Task/Colorful-numbers/Haskell/colorful-numbers.hs
index 097645267c..bdecdbc569 100644
--- a/Task/Colorful-numbers/Haskell/colorful-numbers.hs
+++ b/Task/Colorful-numbers/Haskell/colorful-numbers.hs
@@ -1,23 +1,21 @@
-import Data.List ( nub )
-import Data.List.Split ( divvy )
-import Data.Char ( digitToInt )
+import Data.Char (digitToInt)
+isColorful :: Int -> Bool
+isColorful n
+ | n < 0 = error "Only non-negative integers are allowed"
+ | n == 0 || n == 1 = True
+ | 0 `elem` digits = False
+ | 1 `elem` digits = False
+ | not (distinct digits) = False
+ | not (distinct subpros) = False
+ | otherwise = True
+ where
+ digits = map digitToInt (show n)
+ subpros = [(prods !! i) `div` (prods !! j) |j <- [0..length(digits)], i <- [(j+1)..length(digits)]]
+ prods = scanl (*) 1 digits
-isColourful :: Integer -> Bool
-isColourful n
- |n >= 0 && n <= 10 = True
- |n > 10 && n < 100 = ((length s) == (length $ nub s)) &&
- (not $ any (\c -> elem c "01") s)
- |n >= 100 = ((length s) == (length $ nub s)) && (not $ any (\c -> elem c "01") s)
- && ((length products) == (length $ nub products))
- where
- s :: String
- s = show n
- products :: [Int]
- products = map (\p -> (digitToInt $ head p) * (digitToInt $ last p))
- $ divvy 2 1 s
+distinct :: Eq a => [a] -> Bool
+distinct [] = True
+distinct [a] = True
+distinct (x:xs) = distinct xs && (x `notElem` xs)
-solution1 :: [Integer]
-solution1 = filter isColourful [0 .. 100]
-
-solution2 :: Integer
-solution2 = head $ filter isColourful [98765432, 98765431 ..]
+-- Note, for s2, I started at 98762543 as it is the largest number that doesn't 'obviously' violate the colourful condition. Everything else either has 2*3 = 6; 2*4 = 8; 1 or 0 or a repeat digit. This was a rather random optimisation.
diff --git a/Task/Colour-bars-Display/Aquarius-BASIC/colour-bars-display.basic b/Task/Colour-bars-Display/Aquarius-BASIC/colour-bars-display.basic
new file mode 100644
index 0000000000..d21d2bb53c
--- /dev/null
+++ b/Task/Colour-bars-Display/Aquarius-BASIC/colour-bars-display.basic
@@ -0,0 +1,8 @@
+10 PRINT CHR$(11)
+20 CS=12328+1024
+30 FOR Y=0 TO 23
+40 FOR X=0 TO 15
+50 POKE CS+40*Y+X+16,X
+60 NEXT
+70 NEXT
+80 GOTO 80
diff --git a/Task/Colour-bars-Display/Atari-BASIC/colour-bars-display.basic b/Task/Colour-bars-Display/Atari-BASIC/colour-bars-display.basic
new file mode 100644
index 0000000000..a8eeba3831
--- /dev/null
+++ b/Task/Colour-bars-Display/Atari-BASIC/colour-bars-display.basic
@@ -0,0 +1,10 @@
+10 GRAPHICS 11:X=0
+20 FOR C=0 TO 15:COLOR C
+30 FOR DX=0 TO 4
+40 PLOT X+DX,0
+50 DRAWTO X+DX,191
+60 NEXT DX
+70 X=X+5
+80 NEXT C
+90 REM WAIT FOR JOYSTICK FIRE BUTTON PRESS
+100 IF STRIG(0)=1 THEN 100
diff --git a/Task/Colour-bars-Display/Crystal/colour-bars-display.cr b/Task/Colour-bars-Display/Crystal/colour-bars-display.cr
new file mode 100644
index 0000000000..f2ca7972d4
--- /dev/null
+++ b/Task/Colour-bars-Display/Crystal/colour-bars-display.cr
@@ -0,0 +1,9 @@
+require "colorize"
+
+10.times do
+ [:black, :red, :green, :blue, :magenta, :cyan, :yellow, :white].each do |colour|
+ print ("█" * 8).colorize colour
+ end
+ Colorize.reset
+ puts
+end
diff --git a/Task/Colour-bars-Display/Nim/colour-bars-display.nim b/Task/Colour-bars-Display/Nim/colour-bars-display.nim
index 77cebe5d54..17e18f999f 100644
--- a/Task/Colour-bars-Display/Nim/colour-bars-display.nim
+++ b/Task/Colour-bars-Display/Nim/colour-bars-display.nim
@@ -1,58 +1,41 @@
-import gintro/[glib, gobject, gtk, gio, cairo]
+import cairo
const
- Width = 400
- Height = 300
+ Width = 600
+ Height = 400
-#---------------------------------------------------------------------------------------------------
-proc draw(area: DrawingArea; context: Context) =
+proc drawBars(surface: ptr Surface) =
## Draw the color bars.
- const Colors = [[0.0, 0.0, 0.0], [255.0, 0.0, 0.0],
- [0.0, 255.0, 0.0], [0.0, 0.0, 255.0],
- [255.0, 0.0, 255.0], [0.0, 255.0, 255.0],
- [255.0, 255.0, 0.0], [255.0, 255.0, 255.0]]
+ const Colors = [(0.0, 0.0, 0.0), # Black.
+ (1.0, 0.0, 0.0), # Red.
+ (0.0, 1.0, 0.0), # Green.
+ (0.0, 0.0, 1.0), # Blue.
+ (1.0, 0.0, 1.0), # Magenta.
+ (0.0, 1.0, 1.0), # Cyan.
+ (1.0, 1.0, 0.0), # Yellow.
+ (1.0, 1.0, 1.0) # White.
+ ]
const
RectWidth = float(Width div Colors.len)
RectHeight = float(Height)
+ let context = create(surface)
+
var x = 0.0
- for color in Colors:
+ for (r, g, b) in Colors:
context.rectangle(x, 0, RectWidth, RectHeight)
- context.setSource(color)
+ context.setSourceRgb(r, g, b)
context.fill()
x += RectWidth
-#---------------------------------------------------------------------------------------------------
+ context.destroy()
-proc onDraw(area: DrawingArea; context: Context; data: pointer): bool =
- ## Callback to draw/redraw the drawing area contents.
- area.draw(context)
- result = true
-
-#---------------------------------------------------------------------------------------------------
-
-proc activate(app: Application) =
- ## Activate the application.
-
- let window = app.newApplicationWindow()
- window.setSizeRequest(Width, Height)
- window.setTitle("Color bars")
-
- # Create the drawing area.
- let area = newDrawingArea()
- window.add(area)
-
- # Connect the "draw" event to the callback to draw the spiral.
- discard area.connect("draw", ondraw, pointer(nil))
-
- window.showAll()
-
-#———————————————————————————————————————————————————————————————————————————————————————————————————
-
-let app = newApplication(Application, "Rosetta.ColorBars")
-discard app.connect("activate", activate)
-discard app.run()
+let surface = imageSurfaceCreate(FormatRgb24, 600, 400)
+surface.drawBars()
+if surface.writeToPng("color_bars.png") != StatusSuccess:
+ quit "Error while writing file.", QuitFailure
+surface.destroy()
diff --git a/Task/Colour-pinstripe-Display/Nim/colour-pinstripe-display.nim b/Task/Colour-pinstripe-Display/Nim/colour-pinstripe-display.nim
index d560f6940c..8be6b5c802 100644
--- a/Task/Colour-pinstripe-Display/Nim/colour-pinstripe-display.nim
+++ b/Task/Colour-pinstripe-Display/Nim/colour-pinstripe-display.nim
@@ -1,63 +1,55 @@
-import gintro/[glib, gobject, gtk, gio, cairo]
+import gtk2, gdk2, glib2, cairo
const
Width = 420
Height = 420
-const Colors = [[0.0, 0.0, 0.0], [255.0, 0.0, 0.0],
- [0.0, 255.0, 0.0], [0.0, 0.0, 255.0],
- [255.0, 0.0, 255.0], [0.0, 255.0, 255.0],
- [255.0, 255.0, 0.0], [255.0, 255.0, 255.0]]
+const Colors = [(0.0, 0.0, 0.0), (1.0, 0.0, 0.0),
+ (0.0, 1.0, 0.0), (0.0, 0.0, 1.0),
+ (1.0, 0.0, 1.0), (0.0, 1.0, 1.0),
+ (1.0, 1.0, 0.0), (1.0, 1.0, 1.0)]
-#---------------------------------------------------------------------------------------------------
-proc draw(area: DrawingArea; context: Context) =
+proc onExposeEvent(widget: PWidget; event: PEventExpose; data: Pgpointer): gboolean {.cdecl.} =
## Draw the color bars.
const lineHeight = Height div 4
+ let cr = cairo_create(widget.window)
+
var y = 0.0
for lineWidth in [1.0, 2.0, 3.0, 4.0]:
- context.setLineWidth(lineWidth)
+ cr.setLineWidth(lineWidth)
var x = 0.0
var colorIndex = 0
while x < Width:
- context.setSource(Colors[colorIndex])
- context.moveTo(x, y)
- context.lineTo(x, y + lineHeight)
- context.stroke()
+ let (r, g, b) = Colors[colorIndex]
+ cr.setSourceRgb(r, g, b)
+ cr.moveTo(x, y)
+ cr.lineTo(x, y + lineHeight)
+ cr.stroke()
colorIndex = (colorIndex + 1) mod Colors.len
x += lineWidth
y += lineHeight
-#---------------------------------------------------------------------------------------------------
+ cr.destroy()
-proc onDraw(area: DrawingArea; context: Context; data: pointer): bool =
- ## Callback to draw/redraw the drawing area contents.
- area.draw(context)
- result = true
+proc onDestroyEvent(widget: PWidget; data: Pgpointer): gboolean {.cdecl.} =
+ ## Quit the application.
+ main_quit()
-#---------------------------------------------------------------------------------------------------
-proc activate(app: Application) =
- ## Activate the application.
+nim_init()
+let window = window_new(gtk2.WINDOW_TOPLEVEL)
+window.set_title("Color pinstripe")
- let window = app.newApplicationWindow()
- window.setSizeRequest(Width, Height)
- window.setTitle("Color pinstripe")
+let drawingArea = drawing_area_new()
+window.add drawingArea
+drawingArea.set_size_request(Width, Height)
- # Create the drawing area.
- let area = newDrawingArea()
- window.add(area)
+discard drawingArea.signal_connect("expose-event", SIGNAL_FUNC(onExposeEvent), nil)
+discard window.signal_connect("destroy", SIGNAL_FUNC(onDestroyEvent), nil)
- # Connect the "draw" event to the callback to draw the color bars.
- discard area.connect("draw", ondraw, pointer(nil))
-
- window.showAll()
-
-#———————————————————————————————————————————————————————————————————————————————————————————————————
-
-let app = newApplication(Application, "Rosetta.ColorPinstripe")
-discard app.connect("activate", activate)
-discard app.run()
+window.show_all()
+main()
diff --git a/Task/Colour-pinstripe-Printer/Nim/colour-pinstripe-printer.nim b/Task/Colour-pinstripe-Printer/Nim/colour-pinstripe-printer.nim
index fedb55ffff..18f983f387 100644
--- a/Task/Colour-pinstripe-Printer/Nim/colour-pinstripe-printer.nim
+++ b/Task/Colour-pinstripe-Printer/Nim/colour-pinstripe-printer.nim
@@ -1,22 +1,66 @@
-import gintro/[glib, gobject, gtk, gio, cairo]
+import gtk2, glib2, cairo
-const Colors = [[0.0, 0.0, 0.0], [255.0, 0.0, 0.0],
- [0.0, 255.0, 0.0], [0.0, 0.0, 255.0],
- [255.0, 0.0, 255.0], [0.0, 255.0, 255.0],
- [255.0, 255.0, 0.0], [255.0, 255.0, 255.0]]
+###############################################################################
+# Missing declarations needed for print operations.
-#---------------------------------------------------------------------------------------------------
+when defined(win32):
+ const lib = "libgtk-win32-2.0-0.dll"
+elif defined(macosx):
+ const lib = "(libgtk-quartz-2.0.0.dylib|libgtk-x11-2.0.dylib)"
+else:
+ const lib = "libgtk-x11-2.0.so(|.0)"
-proc beginPrint(op: PrintOperation; printContext: PrintContext; data: pointer) =
- ## Process signal "begin_print", that is set the number of pages to print.
- op.setNPages(1)
+# Missing type definitions.
+type
+ PrintOperation = PObject
+ PrintContext = PObject
+ PrintOperationAction = enum
+ PRINT_OPERATION_ACTION_PRINT_DIALOG
+ PRINT_OPERATION_ACTION_PRINT
+ PRINT_OPERATION_ACTION_PREVIEW
+ PRINT_OPERATION_ACTION_EXPORT
+ PrintOperationResult = enum
+ PRINT_OPERATION_RESULT_ERROR
+ PRINT_OPERATION_RESULT_APPLY
+ PRINT_OPERATION_RESULT_CANCEL
+ PRINT_OPERATION_RESULT_IN_PROGRESS
-#---------------------------------------------------------------------------------------------------
+# Missing external procedures.
+proc print_operation_new(): PrintOperation {.cdecl,
+ importc: "gtk_print_operation_new", dynlib: lib.}
+proc print_operation_run(op: PrintOperation; action: PrintOperationAction;
+ parent: PWindow; error: pointer): PrintOperationResult {.cdecl,
+ importc: "gtk_print_operation_run", dynlib: lib.}
+proc set_n_pages(op: PrintOperation; n: gint) {.cdecl,
+ importc: "gtk_print_operation_set_n_pages", dynlib: lib.}
+proc get_cairo_context(printContext: PrintContext): ptr Context {.cdecl,
+ importc: "gtk_print_context_get_cairo_context", dynlib: lib.}
+proc width(printContext: PrintContext): cdouble {.cdecl,
+ importc: "gtk_print_context_get_width", dynlib: lib.}
+proc height(printContext: PrintContext): cdouble {.cdecl,
+ importc: "gtk_print_context_get_height", dynlib: lib.}
-proc drawPage(op: PrintOperation; printContext: PrintContext; pageNum: int; data: pointer) =
- ## Draw a page.
- let context = printContext.getCairoContext()
+###############################################################################
+
+const Colors = [(0.0, 0.0, 0.0), (1.0, 0.0, 0.0),
+ (0.0, 1.0, 0.0), (0.0, 0.0, 1.0),
+ (1.0, 0.0, 1.0), (0.0, 1.0, 1.0),
+ (1.0, 1.0, 0.0), (1.0, 1.0, 1.0)]
+
+
+proc beginPrint(op: PrintOperation; printContext: PrintContext;
+ data: Pgpointer): gboolean {.cdecl.} =
+ ## Process "begin_print" signal.
+ op.setNPages(1) # Print one page.
+ result = true
+
+
+proc drawPage(op: PrintOperation; printContext: PrintContext;
+ pageNum: int; data: Pgpointer): gboolean {.cdecl.} =
+ ## Process "draw_page" signal.
+
+ let context = printContext.get_cairo_context()
let lineHeight = printContext.height / 4
var y = 0.0
@@ -25,7 +69,8 @@ proc drawPage(op: PrintOperation; printContext: PrintContext; pageNum: int; data
var x = 0.0
var colorIndex = 0
while x < printContext.width:
- context.setSource(Colors[colorIndex])
+ let (r, g, b) = Colors[colorIndex]
+ context.setSourceRgb(r, g, b)
context.moveTo(x, y)
context.lineTo(x, y + lineHeight)
context.stroke()
@@ -33,21 +78,13 @@ proc drawPage(op: PrintOperation; printContext: PrintContext; pageNum: int; data
x += lineWidth
y += lineHeight
-#---------------------------------------------------------------------------------------------------
+ result = true/* {{header|Nim}} */
-proc activate(app: Application) =
- ## Activate the application.
- # Launch a print operation.
- let op = newPrintOperation()
- op.connect("begin_print", beginPrint, pointer(nil))
- op.connect("draw_page", drawPage, pointer(nil))
+nim_init()
- # Run the print dialog.
- discard op.run(printDialog)
-
-#———————————————————————————————————————————————————————————————————————————————————————————————————
-
-let app = newApplication(Application, "Rosetta.ColorPinstripe")
-discard app.connect("activate", activate)
-discard app.run()
+# Print the pinstripe.
+let op = print_operation_new()
+discard op.g_signal_connect("begin_print", G_CALLBACK(begin_print), nil)
+discard op.g_signal_connect("draw_page", G_CALLBACK(draw_page), nil)
+discard op.print_operation_run(PRINT_OPERATION_ACTION_PRINT_DIALOG, nil, nil)
diff --git a/Task/Combinations-and-permutations/Quackery/combinations-and-permutations.quackery b/Task/Combinations-and-permutations/Quackery/combinations-and-permutations.quackery
new file mode 100644
index 0000000000..68b70aa74c
--- /dev/null
+++ b/Task/Combinations-and-permutations/Quackery/combinations-and-permutations.quackery
@@ -0,0 +1,21 @@
+ [ 1 swap times [ i^ 1+ * ] ] is ! ( n --> n )
+
+ [ dip dup - ! dip ! / ] is p ( n n --> n )
+
+ [ tuck p swap ! / ] is c ( n n --> n )
+
+ ' [ [ 1 0 ] [ 12 4 ] [ 60 20 ] [ 105 103 ] [ 15000 333 ] ]
+ witheach
+ [ unpack 2dup
+ say " P("
+ swap echo say "," echo
+ say ") = "
+ p shorten echo$ cr ]
+ cr
+ ' [ [ 10 5 ] [ 60 30 ] [ 50 48 ] [ 900 675 ] [ 970 730 ] ]
+ witheach
+ [ unpack 2dup
+ say " C("
+ swap echo say "," echo
+ say ") = "
+ c shorten echo$ cr ]
diff --git a/Task/Combinations-with-repetitions/Jq/combinations-with-repetitions-1.jq b/Task/Combinations-with-repetitions/Jq/combinations-with-repetitions-1.jq
index 3972206ac5..bb25c96913 100644
--- a/Task/Combinations-with-repetitions/Jq/combinations-with-repetitions-1.jq
+++ b/Task/Combinations-with-repetitions/Jq/combinations-with-repetitions-1.jq
@@ -6,3 +6,5 @@ def pick(n):
else ([.[m]] + pick(n-1; m)), pick(n; m+1)
end;
pick(n;0) ;
+
+def count(s): reduce s as $_ (0; .+1);
diff --git a/Task/Combinations-with-repetitions/Jq/combinations-with-repetitions-2.jq b/Task/Combinations-with-repetitions/Jq/combinations-with-repetitions-2.jq
index 6c2692b448..50f06bd1e4 100644
--- a/Task/Combinations-with-repetitions/Jq/combinations-with-repetitions-2.jq
+++ b/Task/Combinations-with-repetitions/Jq/combinations-with-repetitions-2.jq
@@ -1,4 +1,4 @@
- "Pick 2:",
+"Pick 2:",
(["iced", "jam", "plain"] | pick(2)),
- ([[range(0;10)] | pick(3)] | length) as $n
- | "There are \($n) ways to pick 3 objects with replacement from 10."
+ (count( [range(0;10)] | pick(3)) as $n
+ | "There are \($n) ways to pick 3 objects with replacement from 10.")
diff --git a/Task/Combinations/M2000-Interpreter/combinations-1.m2000 b/Task/Combinations/M2000-Interpreter/combinations-1.m2000
index a5f1f5bb7e..47e46a34ce 100644
--- a/Task/Combinations/M2000-Interpreter/combinations-1.m2000
+++ b/Task/Combinations/M2000-Interpreter/combinations-1.m2000
@@ -1,41 +1,32 @@
Module Checkit {
- Global a$
- Document a$
- Module Combinations (m as long, n as long){
+ Function Combinations (m as long, n as long){
+ Global a$
+ Document a$
Module Level (n, s, h) {
- If n=1 then {
- while Len(s) {
- Print h, car(s)
- ToClipBoard()
+ If n=1 then
+ while Len(s)
+ a$<=h#str$("-")+"-"+car(s)#str$()+{
+ }
s=cdr(s)
- }
- } Else {
- While len(s) {
+ End While
+ Else
+ While len(s)
call Level n-1, cdr(s), cons(h, car(s))
s=cdr(s)
- }
- }
- Sub ToClipBoard()
- local m=each(h)
- Local b$=""
- While m {
- b$+=If$(Len(b$)<>0->" ","")+Format$("{0::-10}",Array(m))
- }
- b$+=If$(Len(b$)<>0->" ","")+Format$("{0::-10}",Array(s,0))+{
- }
- a$<=b$ ' assign to global need <=
- End Sub
+ End While
+ End if
}
If m<1 or n<1 then Error
s=(,)
- for i=0 to n-1 {
- s=cons(s, (i,))
- }
+ for i=0 to n-1
+ Append s, (i,)
+ next
+ s=s#sort()
Head=(,)
Call Level m, s, Head
+ =a$
}
- Clear a$
- Combinations 3, 5
- ClipBoard a$
+ ClipBoard Combinations( 3, 5)
+ report clipboard$
}
Checkit
diff --git a/Task/Combinations/M2000-Interpreter/combinations-2.m2000 b/Task/Combinations/M2000-Interpreter/combinations-2.m2000
index 96566c892d..9d851f853b 100644
--- a/Task/Combinations/M2000-Interpreter/combinations-2.m2000
+++ b/Task/Combinations/M2000-Interpreter/combinations-2.m2000
@@ -1,45 +1,55 @@
Module StepByStep {
- Function CombinationsStep (a, nn) {
- c1=lambda (&f, &a) ->{
- =car(a) : a=cdr(a) : f=len(a)=0
- }
- m=len(a)
+ Function CombinationsStep (a, nn) {
+ c1=lambda (&f, &a) ->{
+ =car(a) : a=cdr(a) : f=len(a)=0
+ }
+ m=len(a)
+ c=c1
+ n=m-nn+1
+ p=2
+ While m>n
+ c1=lambda c2=c,n=p, z=(,) (&f, &m) ->{
+ if len(z)=0 then z=cdr(m)
+ =cons(car(m),c2(&f, &z))
+ if f then z=(,) : m=cdr(m) : f=len(m)+len(z)n {
- c1=lambda c2=c,n=p, z=(,) (&f, &m) ->{
- if len(z)=0 then z=cdr(m)
- =cons(car(m),c2(&f, &z))
- if f then z=(,) : m=cdr(m) : f=len(m)+len(z) {
+ =c(&f, &a)
}
- =lambda c, a (&f) -> {
- =c(&f, &a)
- }
- }
- k=false
- StepA=CombinationsStep((1, 2, 3, 4,5), 3)
- while not k {
- Print StepA(&k)
- }
- k=false
- StepA=CombinationsStep((0, 1, 2, 3, 4), 3)
- while not k {
- Print StepA(&k)
- }
- k=false
- StepA=CombinationsStep(("A", "B", "C", "D","E"), 3)
- while not k {
- Print StepA(&k)
- }
- k=false
- StepA=CombinationsStep(("CAT", "DOG", "BAT"), 2)
- while not k {
- Print StepA(&k)
- }
+ }
+ enum out {screen="", file="out.txt"}
+ m=each(out)
+ while m
+ open eval(m) for output as #f
+ k=false
+ StepA=CombinationsStep((1, 2, 3, 4,5), 3)
+ While not k
+ Print #f, StepA(&k)#str$()
+ End While
+ Print #f
+ k=false
+ StepA=CombinationsStep((0, 1, 2, 3, 4), 3)
+ While not k
+ Print #f, StepA(&k)#str$()
+ End While
+ Print #f
+ k=false
+ StepA=CombinationsStep(("A", "B", "C", "D","E"), 3)
+ While not k
+ Print #f, StepA(&k)#str$("-")
+ End While
+ Print #f
+ k=false
+ StepA=CombinationsStep(("CAT", "DOG", "BAT"), 2)
+ While not k
+ Print #f, StepA(&k)#str$("-")
+ End While
+ close #f
+ end while
+ win "notepad", dir$+file
}
StepByStep
diff --git a/Task/Combinations/Quackery/combinations-1.quackery b/Task/Combinations/Quackery/combinations-1.quackery
index 697808559d..ccf881afbe 100644
--- a/Task/Combinations/Quackery/combinations-1.quackery
+++ b/Task/Combinations/Quackery/combinations-1.quackery
@@ -1,48 +1,21 @@
- [ 0 swap
- [ dup 0 != while
- dup 1 & if
- [ dip 1+ ]
- 1 >> again ]
- drop ] is bits ( n --> n )
-
- [ [] unrot
- bit times
- [ i bits
- over = if
- [ dip
- [ i join ] ] ]
- drop ] is combnums ( n n --> [ )
-
- [ [] 0 rot
- [ dup 0 != while
- dup 1 & if
- [ dip
- [ dup dip join ] ]
- dip 1+
- 1 >>
- again ]
- 2drop ] is makecomb ( n --> [ )
-
[ over 0 = iff
- [ 2drop [] ] done
- combnums
- [] swap witheach
- [ makecomb
- nested join ] ] is comb ( n n --> [ )
+ [ 2drop ' [ [ ] ] ]
+ done
+ dup [] = iff nip done
+ 1 split rot tuck
+ 1 - over recurse
+ dip [ rot [] ]
+ witheach
+ [ dip over join
+ nested join ]
+ nip unrot recurse join ] is comb ( n [ --> [ )
- [ behead swap witheach max ] is largest ( [ --> n )
+ [ [] swap times
+ [ i^ join ]
+ comb
+ witheach
+ [ witheach
+ [ echo sp ]
+ cr ] ] is task ( n n --> )
- [ 0 rot witheach
- [ [ dip [ over * ] ] + ]
- nip ] is comborder ( [ n --> n )
-
- [ dup [] != while
- sortwith
- [ 2dup join
- largest 1+ dup dip
- [ comborder swap ]
- comborder < ] ] is sortcombs ( [ --> [ )
-
- 3 5 comb
- sortcombs
- witheach [ witheach [ echo sp ] cr ]
+ 3 5 task
diff --git a/Task/Combinations/Quackery/combinations-2.quackery b/Task/Combinations/Quackery/combinations-2.quackery
index 5626470d75..697808559d 100644
--- a/Task/Combinations/Quackery/combinations-2.quackery
+++ b/Task/Combinations/Quackery/combinations-2.quackery
@@ -1,31 +1,48 @@
- [ stack ] is comb.stack
- [ stack ] is comb.items
- [ stack ] is comb.required
- [ stack ] is comb.result
+ [ 0 swap
+ [ dup 0 != while
+ dup 1 & if
+ [ dip 1+ ]
+ 1 >> again ]
+ drop ] is bits ( n --> n )
- [ 1 - comb.items put
- 1+ comb.required put
- 0 comb.stack put
- [] comb.result put
- [ comb.required share
- comb.stack size = if
- [ comb.result take
- comb.stack behead
- drop nested join
- comb.result put ]
- comb.stack take
- dup comb.items share
- = iff
- [ drop
- comb.stack size 1 > iff
- [ 1 comb.stack tally ] ]
- else
- [ dup comb.stack put
- 1+ comb.stack put ]
- comb.stack size 1 = until ]
- comb.items release
- comb.required release
- comb.result take ] is comb ( n n --> )
+ [ [] unrot
+ bit times
+ [ i bits
+ over = if
+ [ dip
+ [ i join ] ] ]
+ drop ] is combnums ( n n --> [ )
+
+ [ [] 0 rot
+ [ dup 0 != while
+ dup 1 & if
+ [ dip
+ [ dup dip join ] ]
+ dip 1+
+ 1 >>
+ again ]
+ 2drop ] is makecomb ( n --> [ )
+
+ [ over 0 = iff
+ [ 2drop [] ] done
+ combnums
+ [] swap witheach
+ [ makecomb
+ nested join ] ] is comb ( n n --> [ )
+
+ [ behead swap witheach max ] is largest ( [ --> n )
+
+ [ 0 rot witheach
+ [ [ dip [ over * ] ] + ]
+ nip ] is comborder ( [ n --> n )
+
+ [ dup [] != while
+ sortwith
+ [ 2dup join
+ largest 1+ dup dip
+ [ comborder swap ]
+ comborder < ] ] is sortcombs ( [ --> [ )
3 5 comb
+ sortcombs
witheach [ witheach [ echo sp ] cr ]
diff --git a/Task/Combinations/Quackery/combinations-3.quackery b/Task/Combinations/Quackery/combinations-3.quackery
index 721a651555..5626470d75 100644
--- a/Task/Combinations/Quackery/combinations-3.quackery
+++ b/Task/Combinations/Quackery/combinations-3.quackery
@@ -1,16 +1,31 @@
- [ dup size dip
- [ witheach
- [ over swap peek swap ] ]
- nip pack ] is arrange ( [ [ --> [ )
+ [ stack ] is comb.stack
+ [ stack ] is comb.items
+ [ stack ] is comb.required
+ [ stack ] is comb.result
+
+ [ 1 - comb.items put
+ 1+ comb.required put
+ 0 comb.stack put
+ [] comb.result put
+ [ comb.required share
+ comb.stack size = if
+ [ comb.result take
+ comb.stack behead
+ drop nested join
+ comb.result put ]
+ comb.stack take
+ dup comb.items share
+ = iff
+ [ drop
+ comb.stack size 1 > iff
+ [ 1 comb.stack tally ] ]
+ else
+ [ dup comb.stack put
+ 1+ comb.stack put ]
+ comb.stack size 1 = until ]
+ comb.items release
+ comb.required release
+ comb.result take ] is comb ( n n --> )
- ' [ 10 20 30 40 50 ]
3 5 comb
- witheach
- [ dip dup arrange
- witheach [ echo sp ]
- cr ]
- drop
- cr
- $ "zero one two three four" nest$
- ' [ 4 3 1 0 1 4 3 ] arrange
- witheach [ echo$ sp ]
+ witheach [ witheach [ echo sp ] cr ]
diff --git a/Task/Combinations/Quackery/combinations-4.quackery b/Task/Combinations/Quackery/combinations-4.quackery
new file mode 100644
index 0000000000..721a651555
--- /dev/null
+++ b/Task/Combinations/Quackery/combinations-4.quackery
@@ -0,0 +1,16 @@
+ [ dup size dip
+ [ witheach
+ [ over swap peek swap ] ]
+ nip pack ] is arrange ( [ [ --> [ )
+
+ ' [ 10 20 30 40 50 ]
+ 3 5 comb
+ witheach
+ [ dip dup arrange
+ witheach [ echo sp ]
+ cr ]
+ drop
+ cr
+ $ "zero one two three four" nest$
+ ' [ 4 3 1 0 1 4 3 ] arrange
+ witheach [ echo$ sp ]
diff --git a/Task/Command-line-arguments/FutureBasic/command-line-arguments.basic b/Task/Command-line-arguments/FutureBasic/command-line-arguments.basic
new file mode 100644
index 0000000000..ed30014088
--- /dev/null
+++ b/Task/Command-line-arguments/FutureBasic/command-line-arguments.basic
@@ -0,0 +1,14 @@
+include "NSLog.incl"
+
+void local fn DoCommandLineArguments
+ CFArrayRef args = fn ProcessInfoArguments
+ NSLog(@"This program is named %@.",args[0])
+ NSLog(@"There are %d arguments.",len(args)-1)
+ for long i = 1 to len(args)-1
+ NSLog(@"the argument #%d is %@", i, args[i])
+ next
+end fn
+
+fn DoCommandLineArguments
+
+HandleEvents
diff --git a/Task/Command-line-arguments/LDPL/command-line-arguments-1.ldpl b/Task/Command-line-arguments/LDPL/command-line-arguments-1.ldpl
new file mode 100644
index 0000000000..26aa218485
--- /dev/null
+++ b/Task/Command-line-arguments/LDPL/command-line-arguments-1.ldpl
@@ -0,0 +1,10 @@
+DATA:
+ argument_count IS NUMBER
+
+PROCEDURE:
+ GET LENGTH OF argv IN argument_count
+ IF argument_count IS EQUAL TO 0 THEN
+ DISPLAY "No arguments!" CRLF
+ ELSE
+ DISPLAY argv:0 CRLF
+ END IF
diff --git a/Task/Command-line-arguments/LDPL/command-line-arguments-2.ldpl b/Task/Command-line-arguments/LDPL/command-line-arguments-2.ldpl
new file mode 100644
index 0000000000..6cc4b9df78
--- /dev/null
+++ b/Task/Command-line-arguments/LDPL/command-line-arguments-2.ldpl
@@ -0,0 +1,6 @@
+$ ldpl argv.ldpl
+* Loading argv.ldpl
+* Compiling argv.ldpl
+* Building argv-bin
+* Saved as argv-bin
+* File(s) compiled successfully.
diff --git a/Task/Command-line-arguments/LDPL/command-line-arguments-3.ldpl b/Task/Command-line-arguments/LDPL/command-line-arguments-3.ldpl
new file mode 100644
index 0000000000..ff51e1fe0c
--- /dev/null
+++ b/Task/Command-line-arguments/LDPL/command-line-arguments-3.ldpl
@@ -0,0 +1,4 @@
+$ ./argv-bin test
+test
+$ ./argv-bin
+No arguments!
diff --git a/Task/Command-line-arguments/Tcl/command-line-arguments-1.tcl b/Task/Command-line-arguments/Tcl/command-line-arguments-1.tcl
new file mode 100644
index 0000000000..3e39085837
--- /dev/null
+++ b/Task/Command-line-arguments/Tcl/command-line-arguments-1.tcl
@@ -0,0 +1,3 @@
+if { $argc >= 1 } {
+ puts [lindex $argv 0]
+}
diff --git a/Task/Command-line-arguments/Tcl/command-line-arguments-2.tcl b/Task/Command-line-arguments/Tcl/command-line-arguments-2.tcl
new file mode 100644
index 0000000000..8db1f98495
--- /dev/null
+++ b/Task/Command-line-arguments/Tcl/command-line-arguments-2.tcl
@@ -0,0 +1,2 @@
+$ tclsh file.tcl test
+test
diff --git a/Task/Command-line-arguments/Tcl/command-line-arguments.tcl b/Task/Command-line-arguments/Tcl/command-line-arguments.tcl
deleted file mode 100644
index 0827817f9e..0000000000
--- a/Task/Command-line-arguments/Tcl/command-line-arguments.tcl
+++ /dev/null
@@ -1,3 +0,0 @@
-if { $argc > 1 } {
- puts [lindex $argv 1]
-}
diff --git a/Task/Command-line-arguments/Zig/command-line-arguments.zig b/Task/Command-line-arguments/Zig/command-line-arguments.zig
new file mode 100644
index 0000000000..5b35ff255c
--- /dev/null
+++ b/Task/Command-line-arguments/Zig/command-line-arguments.zig
@@ -0,0 +1,13 @@
+const std = @import("std");
+
+pub fn main() !void {
+ const stdout = std.io.getStdOut().writer();
+
+ var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
+ defer arena.deinit();
+ const allocator = arena.allocator();
+
+ const args = try std.process.argsAlloc(allocator);
+
+ try stdout.print("{s}\n", .{args});
+}
diff --git a/Task/Compare-a-list-of-strings/BQN/compare-a-list-of-strings-1.bqn b/Task/Compare-a-list-of-strings/BQN/compare-a-list-of-strings-1.bqn
index 513bc811cf..a840cab418 100644
--- a/Task/Compare-a-list-of-strings/BQN/compare-a-list-of-strings-1.bqn
+++ b/Task/Compare-a-list-of-strings/BQN/compare-a-list-of-strings-1.bqn
@@ -1,8 +1 @@
-AllEq ← ⍋≡⍒
-Asc ← ¬∘AllEq∧∧≡⊢
-
-•Show AllEq ⟨"AA", "AA", "AA", "AA"⟩
-•Show Asc ⟨"AA", "AA", "AA", "AA"⟩
-
-•Show AllEq ⟨"AA", "ACB", "BB", "CC"⟩
-•Show Asc ⟨"AA", "ACB", "BB", "CC"⟩
+⊣`
diff --git a/Task/Compare-a-list-of-strings/BQN/compare-a-list-of-strings-2.bqn b/Task/Compare-a-list-of-strings/BQN/compare-a-list-of-strings-2.bqn
index 680eb502aa..51394587b4 100644
--- a/Task/Compare-a-list-of-strings/BQN/compare-a-list-of-strings-2.bqn
+++ b/Task/Compare-a-list-of-strings/BQN/compare-a-list-of-strings-2.bqn
@@ -1,4 +1,8 @@
-1
-0
-0
-1
+AllEq ← ⍋≡⍒ # or ⊣`⊸≡
+Asc ← ⍷∘∧⊸≡
+
+•Show AllEq ⟨"AA", "AA", "AA", "AA"⟩
+•Show Asc ⟨"AA", "AA", "AA", "AA"⟩
+
+•Show AllEq ⟨"AA", "ACB", "BB", "CC"⟩
+•Show Asc ⟨"AA", "ACB", "BB", "CC"⟩
diff --git a/Task/Compare-a-list-of-strings/BQN/compare-a-list-of-strings-3.bqn b/Task/Compare-a-list-of-strings/BQN/compare-a-list-of-strings-3.bqn
new file mode 100644
index 0000000000..680eb502aa
--- /dev/null
+++ b/Task/Compare-a-list-of-strings/BQN/compare-a-list-of-strings-3.bqn
@@ -0,0 +1,4 @@
+1
+0
+0
+1
diff --git a/Task/Compare-a-list-of-strings/Jq/compare-a-list-of-strings-1.jq b/Task/Compare-a-list-of-strings/Jq/compare-a-list-of-strings-1.jq
index 9d9694486b..9a73ae5c6f 100644
--- a/Task/Compare-a-list-of-strings/Jq/compare-a-list-of-strings-1.jq
+++ b/Task/Compare-a-list-of-strings/Jq/compare-a-list-of-strings-1.jq
@@ -1,11 +1,11 @@
# Are the strings all equal?
def lexically_equal:
- . as $in
- | reduce range(0;length-1) as $i
- (true; if . then $in[$i] == $in[$i + 1] else false end);
+ if length <= 1 then true
+ else . as $in
+ | all( range(0;length-1); $in[0] == $in[. + 1])
+ end;
-# Are the strings in strictly ascending order?
+# Are the elements in strictly ascending order?
def lexically_ascending:
. as $in
- | reduce range(0;length-1) as $i
- (true; if . then $in[$i] < $in[$i + 1] else false end);
+ | all( range(0;length-1); $in[.] < $in[. + 1]);
diff --git a/Task/Compare-a-list-of-strings/K/compare-a-list-of-strings.k b/Task/Compare-a-list-of-strings/K/compare-a-list-of-strings.k
new file mode 100644
index 0000000000..94f07991ed
--- /dev/null
+++ b/Task/Compare-a-list-of-strings/K/compare-a-list-of-strings.k
@@ -0,0 +1,2 @@
+alleq:&/1_~':
+asc:&/(*<,)':,:'
diff --git a/Task/Compile-time-calculation/Python/compile-time-calculation.py b/Task/Compile-time-calculation/Python/compile-time-calculation.py
new file mode 100644
index 0000000000..2aa67ebc19
--- /dev/null
+++ b/Task/Compile-time-calculation/Python/compile-time-calculation.py
@@ -0,0 +1 @@
+fc = 10 * 9 * 8 * 7 * 6 * 5 * 4 * 3 * 2
diff --git a/Task/Compound-data-type/M2000-Interpreter/compound-data-type.m2000 b/Task/Compound-data-type/M2000-Interpreter/compound-data-type.m2000
new file mode 100644
index 0000000000..3b9796e35b
--- /dev/null
+++ b/Task/Compound-data-type/M2000-Interpreter/compound-data-type.m2000
@@ -0,0 +1,27 @@
+class point {
+ single x, y
+class:
+ module point (.x, .y) {}
+}
+function global add2(k as point) {
+ k.x+=2
+ =k
+}
+module check {
+ a=point(2.343, 4.556)
+ print a.x, a.y
+ alfa(@add1(a))
+ a=add2(a)
+ alfa(a)
+ print a is type point = true
+
+ sub alfa(k as point)
+ print k.x
+ end sub
+
+ function add1(k as point)
+ k.x+=1
+ =k
+ end function
+}
+check
diff --git a/Task/Concurrent-computing/M2000-Interpreter/concurrent-computing.m2000 b/Task/Concurrent-computing/M2000-Interpreter/concurrent-computing.m2000
index f6093e4fcb..06efefcb69 100644
--- a/Task/Concurrent-computing/M2000-Interpreter/concurrent-computing.m2000
+++ b/Task/Concurrent-computing/M2000-Interpreter/concurrent-computing.m2000
@@ -1,6 +1,6 @@
Thread.Plan Concurrent
Module CheckIt {
- Flush \\ empty stack of values
+ Flush ' empty stack of values
Data "Enjoy", "Rosetta", "Code"
For i=1 to 3 {
Thread {
@@ -13,21 +13,21 @@ Module CheckIt {
Threads
}
Rem : Wait 3000 ' we can use just a wait loop, or the main.task loop
- \\ main.task exit if all threads erased
+ ' main.task exit if all threads erased
Main.Task 30 {
}
-\\ when module exit all threads from this module get a signal to stop.
-\\ we can use Threads Erase to erase all threads.
-\\ Also if we press Esc we do the same
+' when module exit all threads from this module get a signal to stop.
+' we can use Threads Erase to erase all threads.
+' Also if we press Esc we do the same
}
CheckIt
-\\ we can define again the module, and now we get three time each name, but not every time three same names.
-\\ if we change to Threads.Plan Sequential we get always the three same names
-\\ Also in concurrent plan we can use a block to ensure that statements run without other thread executed in parallel.
+' we can define again the module, and now we get three time each name, but not every time three same names.
+' if we change to Threads.Plan Sequential we get always the three same names
+' Also in concurrent plan we can use a block to ensure that statements run without other thread executed in parallel.
Module CheckIt {
- Flush \\ empty stack of values
+ Flush ' empty stack of values
Data "Enjoy", "Rosetta", "Code"
For i=1 to 3 {
Thread {
@@ -42,11 +42,11 @@ Module CheckIt {
Threads
}
Rem : Wait 3000 ' we can use just a wait loop, or the main.task loop
- \\ main.task exit if all threads erased
+ ' main.task exit if all threads erased
Main.Task 30 {
}
-\\ when module exit all threads from this module get a signal to stop.
-\\ we can use Threads Erase to erase all threads.
-\\ Also if we press Esc we do the same
+' when module exit all threads from this module get a signal to stop.
+' we can use Threads Erase to erase all threads.
+' Also if we press Esc we do the same
}
CheckIt
diff --git a/Task/Consecutive-primes-with-ascending-or-descending-differences/ALGOL-68/consecutive-primes-with-ascending-or-descending-differences.alg b/Task/Consecutive-primes-with-ascending-or-descending-differences/ALGOL-68/consecutive-primes-with-ascending-or-descending-differences.alg
index 7b1613f55e..d6d1a27772 100644
--- a/Task/Consecutive-primes-with-ascending-or-descending-differences/ALGOL-68/consecutive-primes-with-ascending-or-descending-differences.alg
+++ b/Task/Consecutive-primes-with-ascending-or-descending-differences/ALGOL-68/consecutive-primes-with-ascending-or-descending-differences.alg
@@ -17,7 +17,7 @@ BEGIN # find sequences of primes where the gaps between the elements #
FOR i TO n DO IF p[ i ] = yes THEN p[ p pos +:= 1 ] := i FI OD;
p[ 1 : p pos ]
END # prime list # ;
- # shos the results of a search #
+ # shows the results of a search #
PROC show sequence = ( []INT primes, STRING seq name, INT seq start, seq length )VOID:
BEGIN
print( ( " The longest sequence of primes with "
diff --git a/Task/Constrained-genericity/Python/constrained-genericity.py b/Task/Constrained-genericity/Python/constrained-genericity.py
new file mode 100644
index 0000000000..1cb6717482
--- /dev/null
+++ b/Task/Constrained-genericity/Python/constrained-genericity.py
@@ -0,0 +1,42 @@
+"""Constrained genericity. Requires Python >= 3.9."""
+
+from typing import Generic
+from typing import Protocol
+from typing import TypeVar
+from typing import runtime_checkable
+
+T = TypeVar("T", covariant=True)
+
+
+@runtime_checkable
+class Edible(Protocol[T]):
+ def eat(self) -> T: ...
+
+
+class FoodBox(Generic[T]):
+ def __init__(self, *food: Edible[T]):
+ # Runtime type checking
+ for item in food:
+ if not isinstance(item, Edible):
+ raise TypeError(f"expected food, found {item.__class__.__name__}")
+
+ self.contents = food
+
+
+class Cheese:
+ def eat(self) -> None:
+ print("eating cheese")
+
+
+class Shoe:
+ def wear(self) -> None:
+ print("wearing shoe")
+
+
+if __name__ == "__main__":
+ box = FoodBox[None](Cheese())
+ for food in box.contents:
+ food.eat()
+
+ # This fails static type checking.
+ box = FoodBox[None](Cheese(), Shoe())
diff --git a/Task/Constrained-random-points-on-a-circle/FutureBasic/constrained-random-points-on-a-circle.basic b/Task/Constrained-random-points-on-a-circle/FutureBasic/constrained-random-points-on-a-circle.basic
new file mode 100644
index 0000000000..11e9b8959d
--- /dev/null
+++ b/Task/Constrained-random-points-on-a-circle/FutureBasic/constrained-random-points-on-a-circle.basic
@@ -0,0 +1,20 @@
+//Constrained random points on a circle
+//https://rosettacode.org/wiki/Constrained_random_points_on_a_circle
+// Translated from Yabasic to FutureBASIC
+
+short i,x,y,r
+window 1,@"Circle",fn CGRectMake(0, 0, 100, 100),NSWindowStyleMaskTitled
+windowcenter(1)
+WindowSetBackgroundColor(1,fn ColorBlack)
+for i = 1 to 100
+ do
+ x = rnd(30)-15
+ y = rnd(30)-15
+ r = fn sqrt(x*x + y*y)
+ until 10 <= r and r <= 15
+
+ oval fill (x+50, y+50,1,1)
+next i
+
+
+handleevents
diff --git a/Task/Continued-fraction-Arithmetic-Construct-from-rational-number/EDSAC-order-code/continued-fraction-arithmetic-construct-from-rational-number.edsac b/Task/Continued-fraction-Arithmetic-Construct-from-rational-number/EDSAC-order-code/continued-fraction-arithmetic-construct-from-rational-number.edsac
index 859cc85936..a9bbf460bf 100644
--- a/Task/Continued-fraction-Arithmetic-Construct-from-rational-number/EDSAC-order-code/continued-fraction-arithmetic-construct-from-rational-number.edsac
+++ b/Task/Continued-fraction-Arithmetic-Construct-from-rational-number/EDSAC-order-code/continued-fraction-arithmetic-construct-from-rational-number.edsac
@@ -28,13 +28,14 @@
[----------------------------------------------------------------------
Modification of library subroutine P7.
Prints signed integer up to 10 digits, left-justified.
- 54 storage locations; working position 4D.
+ 52 storage locations; working position 4D.
Must be loaded at an even address.
Input: Number is at 0D.]
- T 56 K
- GKA3FT42@A49@T31@ADE10@T31@A48@T31@SDTDH44#@NDYFLDT4DS43@TF
- H17@S17@A43@G23@UFS43@T1FV4DAFG50@SFLDUFXFOFFFSFL4FT4DA49@
- T31@A1FA43@G20@XFP1024FP610D@524D!FO46@O26@XFSFL8FT4DE39@
+ [2024-12-25 Fixed bug in print subroutine. Did not affect Rosetta Code output.]
+ T 56 K
+ GKA3FT42@A47@T31@ADE10@T31@A46@T31@SDTDH44#@NDYFLDT4DS43@
+ TFH17@S17@A43@G23@UFS43@T1FV4DAFG48@SFLDUFXFOFFFSFL4FT4DA47@
+ T31@A1FA43@G20@XFT44#ZPFT43ZP1024FP610D@524DO26@XFSFL8FT4DE39@
[----------------------------------------------------------------------
Division subroutine for long positive integers.
diff --git a/Task/Convert-decimal-number-to-rational/Forth/convert-decimal-number-to-rational.fth b/Task/Convert-decimal-number-to-rational/Forth/convert-decimal-number-to-rational-1.fth
similarity index 100%
rename from Task/Convert-decimal-number-to-rational/Forth/convert-decimal-number-to-rational.fth
rename to Task/Convert-decimal-number-to-rational/Forth/convert-decimal-number-to-rational-1.fth
diff --git a/Task/Convert-decimal-number-to-rational/Forth/convert-decimal-number-to-rational-2.fth b/Task/Convert-decimal-number-to-rational/Forth/convert-decimal-number-to-rational-2.fth
new file mode 100644
index 0000000000..dbfe173a7b
--- /dev/null
+++ b/Task/Convert-decimal-number-to-rational/Forth/convert-decimal-number-to-rational-2.fth
@@ -0,0 +1,13 @@
+: RealToRational ( f n1 -- n2 n3)
+ 0 dup rot max-n s>f fswap fdup f0< >r
+ fabs fdup ftrunc f>s 1+ swap ( den num lim real R: neg F: best real)
+ \ helps set integer bounds around target
+ 1+ 1 ?do \ search through possible denominators
+ dup i * over 1- i * ?do \ search within integer limits bounding the real
+ fover fover i s>f j s>f f/ f- fabs fdup frot f<
+ if nip nip j i rot fswap frot then fdrop
+ loop \ e.g. for 3.1419e search only between 3 and 4
+ loop
+
+ fdrop fdrop drop r> if negate then swap
+;
diff --git a/Task/Convert-seconds-to-compound-duration/Langur/convert-seconds-to-compound-duration.langur b/Task/Convert-seconds-to-compound-duration/Langur/convert-seconds-to-compound-duration.langur
index baca41f3e5..4c77456e8b 100644
--- a/Task/Convert-seconds-to-compound-duration/Langur/convert-seconds-to-compound-duration.langur
+++ b/Task/Convert-seconds-to-compound-duration/Langur/convert-seconds-to-compound-duration.langur
@@ -11,7 +11,7 @@ val d = fn(var sec) {
for seconds in [7259, 86400, 6000000] {
val dur = d(seconds)
write "{{seconds:7}} sec = "
- writeln join(", ", for[=[]] k of dur[1] {
+ writeln join(for[=[]] k of dur[1] {
if dur[2][k] != 0: _for ~= ["{{dur[2][k]}} {{dur[1][k]}}"]
- })
+ }, by=", ")
}
diff --git a/Task/Conways-Game-of-Life/Zig/conways-game-of-life.zig b/Task/Conways-Game-of-Life/Zig/conways-game-of-life.zig
new file mode 100644
index 0000000000..524afe1ece
--- /dev/null
+++ b/Task/Conways-Game-of-Life/Zig/conways-game-of-life.zig
@@ -0,0 +1,85 @@
+const std = @import("std");
+const mem = std.mem;
+
+pub fn main() !void {
+ // ---------------------------- pseudo random number generator
+ var prng = std.Random.DefaultPrng.init(blk: {
+ var seed: u64 = undefined;
+ std.posix.getrandom(mem.asBytes(&seed)) catch unreachable;
+ break :blk seed;
+ });
+ const random = prng.random();
+ // ----------------------------------------------------------
+ const stdout = std.io.getStdOut();
+ var bw = std.io.bufferedWriter(stdout.writer());
+ const writer = bw.writer();
+ // ----------------------------------------------------------
+ var life = Life(80, 15).init(random);
+ for (0..300) |_| {
+ life.step();
+ try writer.writeByte('\x0c');
+ try writer.print("{}", .{life});
+ try bw.flush();
+ std.time.sleep(comptime (1_000_000_000 / 30)); // 1/30th second
+ }
+}
+fn Life(comptime w: usize, comptime h: usize) type {
+ return struct {
+ const Self = @This();
+ a: Field(w, h),
+ b: Field(w, h),
+
+ fn init(random: std.Random) Self {
+ var life = Self{
+ .a = Field(w, h).init(),
+ .b = Field(w, h).init(),
+ };
+ for (0..w * h / 2) |_| {
+ const x = random.uintLessThan(usize, w);
+ const y = random.uintLessThan(usize, h);
+ life.a.set(x, y, true);
+ }
+ return life;
+ }
+ fn step(self: *Self) void {
+ for (0..h) |y|
+ for (0..w) |x|
+ self.b.set(x, y, self.a.next(x, y));
+ mem.swap(Field(w, h), &self.a, &self.b);
+ }
+ pub fn format(self: *const Self, comptime _: []const u8, _: std.fmt.FormatOptions, writer: anytype) !void {
+ for (0..h) |y| {
+ for (0..w) |x|
+ try writer.writeByte(if (self.a.state(x, y)) '*' else ' ');
+ try writer.writeByte('\n');
+ }
+ }
+ };
+}
+fn Field(comptime w: usize, comptime h: usize) type {
+ return struct {
+ const Self = @This();
+ s: std.StaticBitSet(w * h),
+
+ fn init() Self {
+ return .{ .s = std.StaticBitSet(w * h).initEmpty() };
+ }
+ fn set(self: *Self, x: usize, y: usize, b: bool) void {
+ self.s.setValue(y * w + x, b);
+ }
+ fn next(self: *const Self, x_: usize, y_: usize) bool {
+ var on: usize = 0;
+ // Use wraparound arithmetic, i.e. -%
+ inline for ([3]usize{ x_ -% 1, x_, x_ + 1 }) |x|
+ inline for ([3]usize{ y_ -% 1, y_, y_ + 1 }) |y|
+ if (self.state(x, y)) {
+ on += 1;
+ };
+ return on == 3 or on == 2 and self.state(x_, y_);
+ }
+ fn state(self: *const Self, x: usize, y: usize) bool {
+ if (x >= w or y >= h) return false;
+ return self.s.isSet(y * w + x);
+ }
+ };
+}
diff --git a/Task/Copy-a-string/68000-Assembly/copy-a-string-2.68000 b/Task/Copy-a-string/68000-Assembly/copy-a-string-2.68000
index 7f91645c39..10041191cb 100644
--- a/Task/Copy-a-string/68000-Assembly/copy-a-string-2.68000
+++ b/Task/Copy-a-string/68000-Assembly/copy-a-string-2.68000
@@ -7,10 +7,7 @@ LEA myString,A3
LEA StringRam,A4
CopyString:
-MOVE.B (A3)+,D0
-MOVE.B D0,(A4)+ ;we could have used "MOVE.B (A3)+,(A4)+" but this makes it easier to check for the terminator.
-BEQ Terminated
-BRA CopyString
+MOVE.B (A3)+,(A4)+ ;Copy one byte.
+BNE CopyString ;Not zero, do more bytes.
-Terminated: ;the null terminator is already stored along with the string itself, so we are done.
;program ends here.
diff --git a/Task/Count-in-octal/Go/count-in-octal-4.go b/Task/Count-in-octal/Go/count-in-octal-4.go
index 6f7d6a6ce6..a38069db73 100644
--- a/Task/Count-in-octal/Go/count-in-octal-4.go
+++ b/Task/Count-in-octal/Go/count-in-octal-4.go
@@ -1,5 +1,6 @@
+package main
import (
- "big"
+ "math/big"
"fmt"
)
diff --git a/Task/Count-in-octal/Zig/count-in-octal.zig b/Task/Count-in-octal/Zig/count-in-octal.zig
index 59ece70ab3..ea4057cc52 100644
--- a/Task/Count-in-octal/Zig/count-in-octal.zig
+++ b/Task/Count-in-octal/Zig/count-in-octal.zig
@@ -1,13 +1,7 @@
const std = @import("std");
-const fmt = std.fmt;
-const warn = std.debug.warn;
pub fn main() void {
- var i: u8 = 0;
- var buf: [3]u8 = undefined;
-
- while (i < 255) : (i += 1) {
- _ = fmt.formatIntBuf(buf[0..], i, 8, false, 0); // buffer, value, base, uppercase, width
- warn("{}\n", buf);
+ for(0..255) |i| {
+ std.debug.print("{o}\n", .{i});
}
}
diff --git a/Task/Count-occurrences-of-a-substring/Langur/count-occurrences-of-a-substring.langur b/Task/Count-occurrences-of-a-substring/Langur/count-occurrences-of-a-substring.langur
index 868b9d305f..8ce8e87c0b 100644
--- a/Task/Count-occurrences-of-a-substring/Langur/count-occurrences-of-a-substring.langur
+++ b/Task/Count-occurrences-of-a-substring/Langur/count-occurrences-of-a-substring.langur
@@ -1,2 +1,2 @@
-writeln len(indices("th", "the three truths"))
-writeln len(indices("abab", "ababababab"))
+writeln len(indices("the three truths", by="th"))
+writeln len(indices("ababababab", by="abab"))
diff --git a/Task/Count-occurrences-of-a-substring/M2000-Interpreter/count-occurrences-of-a-substring.m2000 b/Task/Count-occurrences-of-a-substring/M2000-Interpreter/count-occurrences-of-a-substring.m2000
new file mode 100644
index 0000000000..e95415b220
--- /dev/null
+++ b/Task/Count-occurrences-of-a-substring/M2000-Interpreter/count-occurrences-of-a-substring.m2000
@@ -0,0 +1,15 @@
+module Count_occurrences_of_a_substring {
+ print @countSubstring("the three truths","th") '3
+ print @countSubstring("ababababab","abab") '2
+ function countSubstring(a$, b$)
+ local k=1, count
+ do
+ k=instr(a$, b$, k)
+ if k<1 then exit
+ count++
+ k+=len(b$)
+ always
+ =count
+ end function
+}
+Count_occurrences_of_a_substring
diff --git a/Task/Count-occurrences-of-a-substring/Zig/count-occurrences-of-a-substring.zig b/Task/Count-occurrences-of-a-substring/Zig/count-occurrences-of-a-substring.zig
new file mode 100644
index 0000000000..103eb1c190
--- /dev/null
+++ b/Task/Count-occurrences-of-a-substring/Zig/count-occurrences-of-a-substring.zig
@@ -0,0 +1,7 @@
+const std = @import("std");
+
+pub fn main() void {
+ std.debug.print("{d}\n", .{
+ std.mem.count(u8, "the three truths", "th")
+ });
+}
diff --git a/Task/Cuban-primes/Quackery/cuban-primes.quackery b/Task/Cuban-primes/Quackery/cuban-primes.quackery
new file mode 100644
index 0000000000..953bc53225
--- /dev/null
+++ b/Task/Cuban-primes/Quackery/cuban-primes.quackery
@@ -0,0 +1,24 @@
+ say "The first 200 cuban primes:"
+ [] [] 1
+ 0 temp put
+ [ 6 temp tally
+ temp share +
+ dup prime if
+ [ dup dip join ]
+ over size 200 = until ]
+ drop
+ witheach
+ [ number$ +commas nested join ]
+ 72 wrap$
+ temp release
+ cr cr
+ say "The 100,000th cuban prime is "
+ 0 1
+ 0 temp put
+ [ 6 temp tally
+ temp share + dup prime if
+ [ dip 1+ ]
+ over 100000 = until ]
+ nip number$ +commas echo$
+ char . emit
+ temp release
diff --git a/Task/Currying/M2000-Interpreter/currying-1.m2000 b/Task/Currying/M2000-Interpreter/currying-1.m2000
deleted file mode 100644
index fa7e6533d1..0000000000
--- a/Task/Currying/M2000-Interpreter/currying-1.m2000
+++ /dev/null
@@ -1,42 +0,0 @@
-Module LikeGroovy {
- divide=lambda (x, y)->x/y
- partsof120=lambda divide ->divide(120, ![])
- Print "half of 120 is ";partsof120(2)
- Print "a third is ";partsof120(3)
- Print "and a quarter is ";partsof120(4)
-}
-LikeGroovy
-
-Module Joke {
- \\ we can call F1(), with any number of arguments, and always read one and then
- \\ call itself passing the remain arguments
- \\ ![] take stack of values and place it in the next call.
- F1=lambda -> {
- if empty then exit
- Read x
- =x+lambda(![])
- }
-
- Print F1(F1(2),2,F1(-4))=0
- Print F1(-4,F1(2),2)=0
- Print F1(2, F1(F1(2),2))=F1(F1(F1(2),2),2)
- Print F1(F1(F1(2),2),2)=6
- Print F1(2, F1(2, F1(2),2))=F1(F1(F1(2),2, F1(2)),2)
- Print F1(F1(F1(2),2, F1(2)),2)=8
- Print F1(2, F1(10, F1(2, F1(2),2)))=F1(F1(F1(2),2, F1(2)),2, 10)
- Print F1(F1(F1(2),2, F1(2)),2, 10)=18
- Print F1(2,2,2,2,10)=18
- Print F1()=0
-
- Group F2 {
- Sum=0
- Function Add (x){
- .Sum+=x
- =x
- }
- }
- Link F2.Add() to F2()
- Print F1(F1(F1(F2(2)),F2(2), F1(F2(2))),F2(2))=8
- Print F2.Sum=8
-}
-Joke
diff --git a/Task/Currying/M2000-Interpreter/currying-2.m2000 b/Task/Currying/M2000-Interpreter/currying-2.m2000
deleted file mode 100644
index b8aaf91170..0000000000
--- a/Task/Currying/M2000-Interpreter/currying-2.m2000
+++ /dev/null
@@ -1,26 +0,0 @@
-Module Puzzle {
- Global Group F2 {
- Sum=0
- Sum2=0
- Function Add (x){
- .Sum+=x
- =x
- }
- }
- F1=lambda -> {
- if empty then exit
- Read x
- Print ">>>", F2.Sum
- F2.Sum2++ ' add one each time we read x
- =x+lambda(![])
- }
- Link F2.Add() to F2()
- P=F1(F1(F1(F2(2)),F2(2), F1(F2(2))),F2(2))=8
- Print F2.Sum=8
- Print F2.Sum2=7
- \\ We read 7 times x, but we get 8, 2+2+2+2
- \\ So 3 times x was zero, or not?
- \\ but where we pass zero?
- \\ zero return from F1 if no argument pass, so how x get zero??
-}
-Puzzle
diff --git a/Task/Currying/M2000-Interpreter/currying.m2000 b/Task/Currying/M2000-Interpreter/currying.m2000
new file mode 100644
index 0000000000..11e0feb542
--- /dev/null
+++ b/Task/Currying/M2000-Interpreter/currying.m2000
@@ -0,0 +1,59 @@
+Module LikeGroovy {
+ divide=lambda (x, y)->x/y
+ Curry=lambda (f as lambda, k)->(lambda f, k ->(f(k,![])))
+ partsof120=Curry(divide, 120)
+ Print "half of 120 is ";partsof120(2)
+ Print "a third is ";partsof120(3)
+ Print "and a quarter is ";partsof120(4)
+
+ joinTwoWordsWithSymbol=lambda (s, a, b)->a+s+b
+ Assert joinTwoWordsWithSymbol("#","Hello", "World")="Hello#World"
+ concatWords =Curry(joinTwoWordsWithSymbol, " ")
+ Assert concatWords("Hello", "World")="Hello World"
+ prependHello =Curry(concatWords, "Hello")
+ Assert prependHello("World")="Hello World"
+ Print "done"
+}
+LikeGroovy
+Module M2000way {
+ class curry{
+ private:
+ p=stack ' stack of values
+ func$ ' field for the weak reference
+ public:
+ property counter {value } ' readonly
+ class:
+ module curry(.func$) {
+ .p<=[]
+ class value {
+ value () {
+ ' symbol ! used for feeding stack of values from arrays or stacks.
+ ' [] is the current stack (leave emtpy stack as current stack)
+ ' Stack(.p) make a copy of .p (which have a stack object)
+ =function(.func$, !stack(.p), ![])
+ .[counter]++
+ }
+ }
+ this=value() ' make this as a property
+ }
+ }
+ ' using a general function
+ Function Divide(a, b) {
+ =a/b
+ }
+ Print "Divide(10, 6) is ";Divide(10, 5)
+ partsof120=Curry(&Divide(), 120)
+ Print "half of 120 is ";partsof120(2)
+ Print "a third is ";partsof120(3)
+ Print "and a quarter is ";partsof120(4)
+ Print "Use of partsof120 so far: "; partsof120.counter; " times"
+ ' using a lambda function
+ joinTwoWordsWithSymbol=lambda (s, a, b)->a+s+b
+ Assert joinTwoWordsWithSymbol("#","Hello", "World")="Hello#World"
+ concatWords =Curry(&joinTwoWordsWithSymbol, " ")
+ Assert concatWords("Hello", "World")="Hello World"
+ prependHello =Curry(&concatWords, "Hello")
+ Assert prependHello("World")="Hello World"
+ Print "done"
+}
+M2000way
diff --git a/Task/Cyclops-numbers/REXX/cyclops-numbers-1.rexx b/Task/Cyclops-numbers/REXX/cyclops-numbers-1.rexx
deleted file mode 100644
index bc1ab73571..0000000000
--- a/Task/Cyclops-numbers/REXX/cyclops-numbers-1.rexx
+++ /dev/null
@@ -1,55 +0,0 @@
-/*REXX pgm finds 1st N cyclops (Θ) #s, Θ primes, blind Θ primes, palindromic Θ primes*/
-parse arg n cols . /*obtain optional argument from the CL.*/
-if n=='' | n=="," then n= 50 /*Not specified? Then use the default.*/
-if cols=='' | cols=="," then cols= 10 /* " " " " " " */
-call genP /*build array of semaphores for primes.*/
-w= max(10, length( commas(@.#) ) ) /*max width of a number in any column. */
-pri?= 0; bli?= 0; pal?= 0; call 0 ' first ' commas(n) " cyclops numbers"
-pri?= 1; bli?= 0; pal?= 0; call 0 ' first ' commas(n) " prime cyclops numbers"
-pri?= 1; bli?= 1; pal?= 0; call 0 ' first ' commas(n) " blind prime cyclops numbers"
-pri?= 1; bli?= 0; pal?= 1; call 0 ' first ' commas(n) " palindromic prime cyclops numbers"
-exit 0 /*stick a fork in it, we're all done. */
-/*──────────────────────────────────────────────────────────────────────────────────────*/
-commas: parse arg ?; do jc=length(?)-3 to 1 by -3; ?=insert(',', ?, jc); end; return ?
-/*──────────────────────────────────────────────────────────────────────────────────────*/
-0: parse arg title; idx= 1 /*get the title of this output section.*/
- say ' index │'center(title, 1 + cols*(w+1) ) /*display the output title. */
- say '───────┼'center("" , 1 + cols*(w+1), '─') /* " " " separator*/
- finds= 0; $= /*the number of finds (so far); $ list.*/
- do j=0 until finds== n; L= length(j) /*find N cyclops numbers, start at 101.*/
- if L//2==0 then do; j= left(1, L+1, 0) /*Is J an even # of digits? Yes, bump J*/
- iterate /*use a new J that has odd # of digits.*/
- end
- z= pos(0, j); if z\==(L+1)%2 then iterate /* " " " " (zero in mid)? " */
- if pos(0, j, z+1)>0 then iterate /* " " " " (has two 0's)? " */
- if pri? then if \!.j then iterate /*Need a cyclops prime? Then skip.*/
- if bli? then do; ?= space(translate(j, , 0), 0) /*Need a blind cyclops prime ?*/
- if \!.? then iterate /*Not a blind cyclops prime? Then skip.*/
- end
- if pal? then do; r= reverse(j) /*Need a palindromic cyclops prime? */
- if r\==j then iterate /*Cyclops number not palindromic? Skip.*/
- if \!.r then iterate /* " palindrome not prime? " */
- end
- finds= finds + 1 /*bump the number of palindromic primes*/
- $= $ right( commas(j), w) /*add a palindromic prime ──► $ list.*/
- if finds//cols\==0 then iterate /*have we populated a line of output? */
- say center(idx, 7)'│' substr($, 2); $= /*display what we have so far (cols). */
- idx= idx + cols /*bump the index count for the output*/
- end /*j*/
- if $\=='' then say center(idx, 7)"│" substr($, 2) /*possible show residual output.*/
- say '───────┴'center("" , 1 + cols*(w+1), '─'); say
- return
-/*──────────────────────────────────────────────────────────────────────────────────────*/
-genP: !.= 0; hip= 7890987 - 1 /*placeholders for primes (semaphores).*/
- @.1=2; @.2=3; @.3=5; @.4=7; @.5=11; @.6=13 /*define some low primes. */
- !.2=1; !.3=1; !.5=1; !.7=1; !.11=1; !.13=1 /* " " " " flags. */
- #= 6; sq.#= @.# ** 2 /*number of primes so far; prime square*/
- do j=@.#+2 by 2 for max(0, hip%2-@.#%2-1) /*find odd primes from here on. */
- parse var j '' -1 _ /*get the last dec. digit of J.*/
- if _==5 then iterate; if j// 3==0 then iterate /*÷ by 5? ÷ by 3? Skip.*/
- if j// 7==0 then iterate; if j//11==0 then iterate /*÷ " 7? ÷ by 11? " */
- do k=6 while sq.k<=j /* [↓] divide by the known odd primes.*/
- if j // @.k == 0 then iterate j /*Is J ÷ X? Then not prime. ___ */
- end /*k*/ /* [↑] only process numbers ≤ √ J */
- #= #+1; @.#= j; sq.#= j*j; !.j= 1 /*bump # Ps; assign next P; P sq; P# */
- end /*j*/; return
diff --git a/Task/Cyclops-numbers/REXX/cyclops-numbers-2.rexx b/Task/Cyclops-numbers/REXX/cyclops-numbers.rexx
similarity index 100%
rename from Task/Cyclops-numbers/REXX/cyclops-numbers-2.rexx
rename to Task/Cyclops-numbers/REXX/cyclops-numbers.rexx
diff --git a/Task/Cyclotomic-polynomial/FreeBASIC/cyclotomic-polynomial.basic b/Task/Cyclotomic-polynomial/FreeBASIC/cyclotomic-polynomial.basic
new file mode 100644
index 0000000000..9c96e1eb57
--- /dev/null
+++ b/Task/Cyclotomic-polynomial/FreeBASIC/cyclotomic-polynomial.basic
@@ -0,0 +1,137 @@
+#include "isprime.bas"
+
+Type IntArray
+ Dim values(Any) As Integer
+ Dim length As Integer
+End Type
+
+Function distinctPrimeFactors(n As Integer) As IntArray
+ Dim result As IntArray
+ Redim result.values(0)
+ result.length = 0
+
+ For i As Integer = 2 To n
+ If n Mod i = 0 Andalso isPrime(i) Then
+ result.length += 1
+ Redim Preserve result.values(result.length - 1)
+ result.values(result.length - 1) = i
+ While n Mod i = 0
+ n \= i
+ Wend
+ End If
+ Next
+ Return result
+End Function
+
+Function substituteExponent(polynomial As IntArray, exponent As Integer) As IntArray
+ Dim result As IntArray
+ result.length = exponent * (polynomial.length - 1) + 1
+ Redim result.values(result.length - 1)
+
+ For i As Integer = polynomial.length - 1 To 0 Step -1
+ result.values(i * exponent) = polynomial.values(i)
+ Next
+
+ Return result
+End Function
+
+Function exactDivision(dividend As IntArray, divisor As IntArray) As IntArray
+ Dim As Integer i, j
+ Dim result As IntArray
+ result.length = dividend.length - divisor.length + 1
+ Redim result.values(result.length - 1)
+
+ Dim temp(dividend.length - 1) As Integer
+ For i = 0 To dividend.length - 1
+ temp(i) = dividend.values(i)
+ Next
+
+ For i = 0 To dividend.length - divisor.length
+ result.values(i) = temp(i)
+ If temp(i) <> 0 Then
+ For j = 1 To divisor.length - 1
+ temp(i + j) -= divisor.values(j) * temp(i)
+ Next
+ End If
+ Next
+
+ Return result
+End Function
+
+Function cycloPoly(cpIndex As Integer) As IntArray
+ Dim i As Integer
+ Dim polynomial As IntArray
+ polynomial.length = 2
+ Redim polynomial.values(1)
+ polynomial.values(0) = 1
+ polynomial.values(1) = -1
+
+ If cpIndex = 1 Then Return polynomial
+
+ If isPrime(cpIndex) Then
+ Dim result As IntArray
+ result.length = cpIndex
+ Redim result.values(cpIndex - 1)
+ For i = 0 To cpIndex - 1
+ result.values(i) = 1
+ Next
+ Return result
+ End If
+
+ Dim primes As IntArray = distinctPrimeFactors(cpIndex)
+ Dim product As Integer = 1
+
+ For i = 0 To primes.length - 1
+ Dim numerator As IntArray = substituteExponent(polynomial, primes.values(i))
+ polynomial = exactDivision(numerator, polynomial)
+ product *= primes.values(i)
+ Next
+
+ Return substituteExponent(polynomial, cpIndex \ product)
+End Function
+
+Function hasHeight(polynomial As IntArray, coefficient As Integer) As Boolean
+ For i As Integer = 0 To (polynomial.length + 1) \ 2 - 1
+ If Abs(polynomial.values(i)) = coefficient Then Return True
+ Next
+ Return False
+End Function
+
+' Main program
+Print "Task 1: Cyclotomic polynomials for n <= 30:"
+Print "CP( 1) = x - 1"
+
+For cpIndex As Integer = 2 To 30
+ Print Using "CP(##) = "; cpIndex;
+ Dim poly As IntArray = cycloPoly(cpIndex)
+
+ Dim first As Boolean = True
+ For i As Integer = poly.length - 1 To 0 Step -1
+ If poly.values(i) <> 0 Then
+ If Not first Then Print Iif(poly.values(i) > 0, " + ", " ");
+ If poly.values(i) <> 1 Or i = 0 Then
+ Print Iif(poly.values(i) = -1 And i > 0, "- ", Str(poly.values(i)));
+ End If
+
+ If i > 0 Then
+ Print "x";
+ If i > 1 Then Print "^" & i;
+ End If
+ first = False
+ End If
+ Next
+ Print
+Next
+
+Print !"\nTask 2: Smallest cyclotomic polynomial with n or -n as a coefficient:"
+Print "CP( 1) has a coefficient with magnitude 1"
+
+Dim cpIndex As Integer = 2
+For coeff As Integer = 2 To 10
+ While isPrime(cpIndex) Or Not hasHeight(cycloPoly(cpIndex), coeff)
+ cpIndex += 1
+ Wend
+ Print Using "CP(#####) has a coefficient with magnitude &"; cpIndex; coeff
+Next
+
+Sleep
diff --git a/Task/DNS-query/Wren/dns-query-1.wren b/Task/DNS-query/Wren/dns-query-1.wren
deleted file mode 100644
index 728593ed2b..0000000000
--- a/Task/DNS-query/Wren/dns-query-1.wren
+++ /dev/null
@@ -1,9 +0,0 @@
-/* DNS_query.wren */
-
-class Net {
- foreign static lookupHost(host)
-}
-
-var host = "orange.kame.net"
-var addrs = Net.lookupHost(host).split(", ")
-System.print(addrs.join("\n"))
diff --git a/Task/DNS-query/Wren/dns-query-2.wren b/Task/DNS-query/Wren/dns-query-2.wren
deleted file mode 100644
index 266b61a3c3..0000000000
--- a/Task/DNS-query/Wren/dns-query-2.wren
+++ /dev/null
@@ -1,31 +0,0 @@
-/* go run DNS_query.go */
-
-package main
-
-import(
- wren "github.com/crazyinfin8/WrenGo"
- "net"
- "strings"
-)
-
-type any = interface{}
-
-func lookupHost(vm *wren.VM, parameters []any) (any, error) {
- host := parameters[1].(string)
- addrs, err := net.LookupHost(host)
- if err != nil {
- return nil, nil
- }
- return strings.Join(addrs, ", "), nil
-}
-
-func main() {
- vm := wren.NewVM()
- fileName := "DNS_query.wren"
- methodMap := wren.MethodMap{"static lookupHost(_)": lookupHost}
- classMap := wren.ClassMap{"Net": wren.NewClass(nil, nil, methodMap)}
- module := wren.NewModule(classMap)
- vm.SetModule(fileName, module)
- vm.InterpretFile(fileName)
- vm.Free()
-}
diff --git a/Task/DNS-query/Wren/dns-query.wren b/Task/DNS-query/Wren/dns-query.wren
new file mode 100644
index 0000000000..e2ce79fd16
--- /dev/null
+++ b/Task/DNS-query/Wren/dns-query.wren
@@ -0,0 +1,18 @@
+import "os" for Process
+
+var domainName = "www.kame.net"
+System.print(domainName)
+var ipvs = ["IPv4", "IPv6"]
+var args = ["A", "AAAA"]
+for (i in 0..1) {
+ var cmd = "nslookup -querytype=%(args[i]) %(domainName)"
+ var lines = Process.read(cmd).split("\n")
+ var addresses = []
+ for (line in lines.skip(3)) {
+ if (line.startsWith("Address:")) {
+ var address = line[8..-1].trim()
+ addresses.add(address)
+ }
+ }
+ for (address in addresses) System.print("%(ipvs[i]): %(address)")
+}
diff --git a/Task/Date-format/Langur/date-format-1.langur b/Task/Date-format/Langur/date-format-1.langur
index 9375725f6a..48c2cf95d3 100644
--- a/Task/Date-format/Langur/date-format-1.langur
+++ b/Task/Date-format/Langur/date-format-1.langur
@@ -1,2 +1,2 @@
-writeln string(dt//, "2006-01-02")
-writeln string(dt//, "Monday, January 2, 2006")
+writeln string(dt//, fmt="2006-01-02")
+writeln string(dt//, fmt="Monday, January 2, 2006")
diff --git a/Task/Date-manipulation/Langur/date-manipulation.langur b/Task/Date-manipulation/Langur/date-manipulation.langur
index d25c9c940e..674403c0ae 100644
--- a/Task/Date-manipulation/Langur/date-manipulation.langur
+++ b/Task/Date-manipulation/Langur/date-manipulation.langur
@@ -2,13 +2,13 @@ val input = "March 7 2009 7:30pm -05:00"
val iformat = "January 2 2006 3:04pm -07:00"
val oformat = "January 2 2006 3:04pm MST"
-val d1 = datetime(input, iformat)
+val d1 = datetime(input, fmt=iformat)
val d2 = d1 + dr/T12h/
-val d3 = datetime(d2, "US/Arizona")
-val d4 = datetime(d2, zls)
-val d5 = datetime(d2, "Z")
-val d6 = datetime(d2, "+02:30")
-val d7 = datetime(d2, "EST")
+val d3 = datetime(d2, fmt="US/Arizona")
+val d4 = datetime(d2, fmt=zls)
+val d5 = datetime(d2, fmt="Z")
+val d6 = datetime(d2, fmt="+02:30")
+val d7 = datetime(d2, fmt="EST")
writeln "input string: ", input
writeln "input format string: ", iformat
diff --git a/Task/Deal-cards-for-FreeCell/M2000-Interpreter/deal-cards-for-freecell.m2000 b/Task/Deal-cards-for-FreeCell/M2000-Interpreter/deal-cards-for-freecell.m2000
new file mode 100644
index 0000000000..6c81a3e2b7
--- /dev/null
+++ b/Task/Deal-cards-for-FreeCell/M2000-Interpreter/deal-cards-for-freecell.m2000
@@ -0,0 +1,45 @@
+Module FreeCellDeal {
+ deal = lambda ->{
+ ms_lcg = lambda ms_state=0# (seed As currency = -1) ->{
+ If seed <> -1 Then
+ ms_state = seed Mod 2 ^ 31
+ Else
+ ms_state = (214013 * ms_state + 2531011) Mod 2 ^ 31
+ End If
+ = binary.shift(ms_state, -16)
+ }
+ fillbytes = lambda n=0ud ->{=n:n++}
+ dim cards(52) as byte< {
+ call void ms_lcg(game)
+ dim ncards()
+ ncards()=cards()
+ for i = 51 to 0
+ c = ms_lcg() Mod (i +1)
+ Swap ncards(i), ncards(c)
+ next
+ =ncards()
+ }
+ }() ' execute now
+ dim dealcards()
+ string suit = "CDHS", value = "A23456789TJQK"
+ aList=(1, 617)
+ nList=each(alist)
+ while nList
+ Print "Game:"+array(nList)
+ dealcards() = deal(array(nlist))
+ CardDis$ = lambda$ dealcards(), suit, value (c)-> {
+ s = dealcards(51 - c) Mod 4 + 1
+ v = dealcards(51 - c) div 4 + 1
+ =Mid$(value,v, 1)+Mid$(suit,s, 1)
+ }
+ c=0
+ Do
+ Print CardDis$(c);
+ if c mod 8 < 7 then ? " "; Else ?
+ c++
+ until c>51
+ ? : ?
+ end while
+}
+FreeCellDeal
diff --git a/Task/Death-Star/FreeBASIC/death-star.basic b/Task/Death-Star/FreeBASIC/death-star-1.basic
similarity index 100%
rename from Task/Death-Star/FreeBASIC/death-star.basic
rename to Task/Death-Star/FreeBASIC/death-star-1.basic
diff --git a/Task/Death-Star/FreeBASIC/death-star-2.basic b/Task/Death-Star/FreeBASIC/death-star-2.basic
new file mode 100644
index 0000000000..008d4ea2d0
--- /dev/null
+++ b/Task/Death-Star/FreeBASIC/death-star-2.basic
@@ -0,0 +1,100 @@
+Type vector
+ v(2) As Double
+End Type
+
+Type sphere
+ cx As Integer
+ cy As Integer
+ cz As Integer
+ r As Integer
+End Type
+
+Function dot(x As vector, y As vector) As Double
+ Return x.v(0)*y.v(0) + x.v(1)*y.v(1) + x.v(2)*y.v(2)
+End Function
+
+Sub normalizeVector(v As vector)
+ Dim invLen As Double = 1.0 / Sqr(dot(v, v))
+ v.v(0) *= invLen
+ v.v(1) *= invLen
+ v.v(2) *= invLen
+End Sub
+
+Function hitSphere(s As sphere, x As Integer, y As Integer, z1 As Double Ptr, z2 As Double Ptr) As Boolean
+ Dim xx As Integer = x - s.cx
+ Dim yy As Integer = y - s.cy
+ Dim zsq As Integer = s.r*s.r - (xx*xx + yy*yy)
+
+ If zsq >= 0 Then
+ Dim zsqrt As Double = Sqr(zsq)
+ *z1 = s.cz - zsqrt
+ *z2 = s.cz + zsqrt
+ Return True
+ End If
+ Return False
+End Function
+
+Function createDeathStar(posic As sphere, neg As sphere, k As Double, amb As Double, direc As vector) As Any Ptr
+ Dim As Integer w = posic.r * 4
+ Dim As Integer h = posic.r * 3
+
+ Dim As Any Ptr img = Imagecreate(w, h, Rgb(0,0,0))
+
+ Dim vec As vector
+ Dim As Double z1, z2, zs1, zs2
+
+ For y As Integer = posic.cy - posic.r To posic.cy + posic.r
+ For x As Integer = posic.cx - posic.r To posic.cx + posic.r
+ If hitSphere(posic, x, y, @z1, @z2) Then
+ Dim hit As Boolean = hitSphere(neg, x, y, @zs1, @zs2)
+
+ If hit Then
+ If zs1 > z1 Then hit = False
+ If zs2 > z2 Then Continue For
+ End If
+
+ If hit Then
+ vec.v(0) = neg.cx - x
+ vec.v(1) = neg.cy - y
+ vec.v(2) = neg.cz - zs2
+ Else
+ vec.v(0) = x - posic.cx
+ vec.v(1) = y - posic.cy
+ vec.v(2) = z1 - posic.cz
+ End If
+
+ normalizeVector(vec)
+ Dim s As Double = dot(direc, vec)
+ If s < 0 Then s = 0
+
+ Dim lum As Double = 255 * (s^k + amb) / (1 + amb)
+ If lum < 0 Then lum = 0
+ If lum > 255 Then lum = 255
+
+ Dim shade As Integer = lum
+ Pset img, (x + w\2, y + h\2), Rgb(shade, shade, shade)
+ End If
+ Next x
+ Next y
+
+ Return img
+End Function
+
+' Main program
+Screenres 500, 400, 32
+Windowtitle "Death Star FreeBASIC"
+
+Dim direct As vector
+direct.v(0) = 20
+direct.v(1) = -40
+direct.v(2) = -10
+normalizeVector(direct)
+
+Dim posic As sphere = Type(0, 0, 0, 120)
+Dim neg As sphere = Type(-50, -50, -30, 75)
+
+Dim img As Any Ptr = createDeathStar(posic, neg, 1.5, 0.2, direct)
+Put (0, 0), img
+Imagedestroy(img)
+
+Sleep
diff --git a/Task/Death-Star/FutureBasic/death-star-1.basic b/Task/Death-Star/FutureBasic/death-star-1.basic
new file mode 100644
index 0000000000..b46ca64359
--- /dev/null
+++ b/Task/Death-Star/FutureBasic/death-star-1.basic
@@ -0,0 +1,86 @@
+_window = 1
+begin enum 1
+ _circularView
+ _OvalView
+end enum
+
+void local fn BuildWindow
+ CGRect r = fn CGRectMake( 0, 0, 400, 400 )
+ window _window, @"Rosetta Code Death Star", r, NSWindowStyleMaskTitled + NSWindowStyleMaskClosable + NSWindowStyleMaskMiniaturizable
+ WindowSetBackgroundColor( _window, fn ColorBlack )
+
+ r = fn CGRectMake( 20, 20, 360, 360 )
+ subclass view _circularView, r, _window
+
+ r = fn CGRectMake( 50, 170, 200, 180 )
+ subclass view _OvalView,r, _circularView
+end fn
+
+local fn OvalView( tag as NSInteger )
+ CGRect r = fn ViewBounds( tag )
+ ViewSetWantsLayer( tag, YES )
+ CFArrayRef cols = @[fn ColorWithRGB(0.125,0.125,0.125,1),fn ColorWithRGB(0.425,0.425,0.4425,1),fn ColorWithRGB(0.725,0.725,0.725,1),fn ColorWithRGB(0.925,0.925,0.925,1),fn ColorWhite,fn ColorWhite ]
+
+ CALayerRef layer = fn CALayerInit
+ ViewSetLayer( tag, layer )
+ CALayerSetCornerRadius( layer, r.size.height / 2.0 )
+ CALayerSetMasksToBounds( layer, YES )
+ CALayerSetBorderWidth( layer, 0.25 )
+ CALayerSetBorderColor( layer, fn ColorBlue )
+
+ CAGradientLayerRef gradLayer = fn CAGradientLayerInit
+ CAGradientLayerSetColors( gradLayer, cols )
+ CALayerSetCornerRadius( gradLayer, r.size.Height / 2.0 )
+ CAGradientLayerSetStartPoint( gradLayer, fn CGPointMake(1,0) )
+ CAGradientLayerSetEndPoint( gradLayer, fn CGPointMake(0,1) )
+ CALayerSetShadowOffset( gradLayer, fn CGSizeMake( 10, -10 ) )
+ CALayerSetShadowRadius( gradLayer, 3.0 )
+ CALayerSetShadowOpacity( gradLayer, 0.4 )
+ CALayerSetFrame( gradLayer, fn CGRectMake(0,0,200,200) )
+
+ CALayerAddSublayer( layer, gradLayer )
+end fn
+
+local fn CircularView( tag as NSinteger )
+ CGRect r = fn ViewBounds( tag )
+ ViewSetWantsLayer( tag, YES )
+ CFArrayRef cols = @[fn ColorWithRGB(0.125,0.125,0.125,1),fn ColorWithRGB(0.425,0.425,0.4425,1),fn ColorWithRGB(0.725,0.725,0.725,1),fn ColorWithRGB(0.925,0.925,0.925,1),fn ColorWhite,fn ColorWhite ]
+ CALayerRef layer = fn CALayerInit
+
+ ViewSetLayer( tag, layer )
+ CALayerSetCornerRadius( layer, r.size.width / 2.0 )
+ CALayerSetMasksToBounds( layer, YES )
+ CALayerSetBorderWidth( layer, 0.25 )
+ CALayerSetBorderColor( layer, fn ColorBlack )
+
+ CAGradientLayerRef gradLayer = fn CAGradientLayerInit
+ CALayerSetCornerRadius( gradLayer, r.size.width / 2.0 )
+ CAGradientLayerSetColors( gradLayer, cols )
+ CAGradientLayerSetStartPoint( gradLayer, fn CGPointMake( 0,0.2 ) )
+ CAGradientLayerSetEndPoint( gradLayer, fn CGPointMake( 1,1 ) )
+ CALayerSetShadowOffset( gradLayer, fn CGSizeMake( 10, -10 ) )
+ CALayerSetShadowRadius( gradLayer, 3.0 )
+ CALayerSetShadowOpacity( gradLayer, 0.4 )
+ CALayerSetFrame( gradLayer, fn CGRectMake(0,0,360,360) )
+ CALayerAddSublayer( layer, gradLayer )
+end fn
+
+
+void local fn DoDialog( ev as long, tag as long, wnd as long )
+ select ( ev )
+ case _viewDrawRect
+ select ( tag )
+ case _circularView : fn CircularView( tag )
+
+ case _OvalView : fn OvalView( tag)
+
+ end select
+ case _windowWillClose : end
+ end select
+end fn
+
+on dialog fn DoDialog
+
+fn BuildWindow
+
+HandleEvents
diff --git a/Task/Death-Star/FutureBasic/death-star-2.basic b/Task/Death-Star/FutureBasic/death-star-2.basic
new file mode 100644
index 0000000000..18d86f6adf
--- /dev/null
+++ b/Task/Death-Star/FutureBasic/death-star-2.basic
@@ -0,0 +1,60 @@
+_window = 1
+begin enum 1
+ _circularView
+ _ovalView
+end enum
+
+void local fn BuildWindow
+ CGRect r = fn CGRectMake( 0, 0, 400, 400 )
+
+ window _window, @"Death Star", r, NSWindowStyleMaskTitled + NSWindowStyleMaskClosable + NSWindowStyleMaskMiniaturizable
+ WindowSetBackgroundColor( _window, fn ColorBlack )
+
+ r = fn CGRectMake( 20, 20, 360, 360 )
+ subclass view _circularView, r
+
+ r = fn CGRectMake( 0, 120, 200, 200 )
+ subclass view _ovalView, r
+end fn
+
+local fn OvalView( tag as NSInteger )
+ CGRect r = fn ViewBounds( tag )
+ r.size.height *= 0.5
+ CFArrayRef cols = @[fn ColorWithWhite(0.8,1),fn ColorBlack]
+ BezierPathRef path = fn BezierPathWithOvalInRect( r )
+ GradientRef grad = fn GradientWithColors( cols )
+ GraphicsContextSaveGraphicsState
+ AffineTransformRef tx = fn AffineTransformInit
+ NSPoint center = fn CGPointMake( fn CGRectGetMidX(r), fn CGRectGetMidY(r))
+ center.x -= 25
+ AffineTransformTranslate( tx, center.x, center.y )
+ AffineTransformRotateByDegrees( tx, 52 )
+ AffineTransformConcat( tx )
+ GradientDrawInBezierPath( grad, path, 0.0 )
+ GraphicsContextRestoreGraphicsState
+end fn
+
+local fn CircularView( tag as NSinteger )
+ CGRect r = fn ViewBounds( tag )
+ CFArrayRef cols = @[fn ColorWithWhite(0.1,1),fn ColorWhite]
+ BezierPathRef path = fn BezierPathWithOvalInRect( r )
+ GradientRef grad = fn GradientWithColors( cols )
+ GradientDrawInBezierPath( grad, path, 0.0 )
+end fn
+
+void local fn DoDialog( ev as long, tag as long )
+ select ( ev )
+ case _viewDrawRect
+ select ( tag )
+ case _circularView : fn CircularView( tag )
+ case _ovalView : fn OvalView( tag)
+ end select
+ case _windowWillClose : end
+ end select
+end fn
+
+on dialog fn DoDialog
+
+fn BuildWindow
+
+HandleEvents
diff --git a/Task/Deceptive-numbers/Forth/deceptive-numbers.fth b/Task/Deceptive-numbers/Forth/deceptive-numbers.fth
new file mode 100644
index 0000000000..a3289a799e
--- /dev/null
+++ b/Task/Deceptive-numbers/Forth/deceptive-numbers.fth
@@ -0,0 +1,44 @@
+: modpow { c b a -- a^b mod c }
+ c 1 = if 0 exit then
+ 1
+ a c mod to a
+ begin
+ b 0>
+ while
+ b 1 and 1 = if
+ a * c mod
+ then
+ a a * c mod to a
+ b 2/ to b
+ repeat ;
+
+: deceptive? ( n -- ? )
+ dup 2 mod 0= if drop false exit then
+ dup 3 mod 0= if drop false exit then
+ dup 5 mod 0= if drop false exit then
+ dup dup 1- 10 modpow 1 <> if drop false exit then
+ 7 begin
+ 2dup dup * >
+ while
+ 2dup mod 0= if 2drop true exit then
+ 4 +
+ 2dup mod 0= if 2drop true exit then
+ 2 +
+ repeat
+ 2drop false ;
+
+: main ( -- )
+ 0 7 begin
+ over 100 <
+ while
+ dup deceptive? if
+ dup 6 .r
+ swap 1+ swap
+ over 10 mod 0= if cr else space then
+ then
+ 1+
+ repeat
+ 2drop ;
+
+main
+bye
diff --git a/Task/Deceptive-numbers/Langur/deceptive-numbers.langur b/Task/Deceptive-numbers/Langur/deceptive-numbers.langur
index acba2f2f8c..615ec14669 100644
--- a/Task/Deceptive-numbers/Langur/deceptive-numbers.langur
+++ b/Task/Deceptive-numbers/Langur/deceptive-numbers.langur
@@ -1,6 +1,6 @@
val isPrime = fn(i) {
i == 2 or i > 2 and
- not any(fn x: i div x, pseries(2 .. i ^/ 2))
+ not any(series(2 .. i ^/ 2, asconly=true), by=fn x:i div x)
}
var nums = []
diff --git a/Task/Deconvolution-2D+/C++/deconvolution-2d+.cpp b/Task/Deconvolution-2D+/C++/deconvolution-2d+.cpp
index 50449ee68e..04e6133754 100644
--- a/Task/Deconvolution-2D+/C++/deconvolution-2d+.cpp
+++ b/Task/Deconvolution-2D+/C++/deconvolution-2d+.cpp
@@ -6,30 +6,6 @@
#include
#include
-std::complex add(const std::complex& c1, const std::complex& c2) {
- return std::complex(c1.real() + c2.real(), c1.imag() + c2.imag());
-}
-
-std::complex subtract(const std::complex& c1, const std::complex& c2) {
- return std::complex(c1.real() - c2.real(), c1.imag() - c2.imag());
-}
-
-std::complex multiply(const std::complex& c1, const std::complex& c2) {
- return std::complex(c1.real() * c2.real() - c1.imag() * c2.imag(),
- c1.imag() * c2.real() + c1.real() * c2.imag());
-}
-
-std::complex divide(const std::complex& complex, const int32_t& n) {
- return std::complex(complex.real() / n, complex.imag() / n);
-}
-
-std::complex divide(const std::complex& c1, const std::complex& c2) {
- const double rr = c1.real() * c2.real() + c1.imag() * c2.imag();
- const double ii = c1.imag() * c2.real() - c1.real() * c2.imag();
- const double norm = c2.real() *c2.real() + c2.imag() * c2.imag();
- return std::complex(rr / norm, ii / norm);
-}
-
struct Return_Value {
int32_t power_of_two;
std::vector> list;
@@ -62,7 +38,7 @@ void print_3D_vector(const std::vector>>& lists) {
print_2D_vector(lists.back()); std::cout << "]" << std::endl;
}
-Return_Value padAndComplexify(const std::vector& list, const int32_t& power_of_two) {
+Return_Value pad_and_complexify(const std::vector& list, const int32_t& power_of_two) {
const int32_t padded_vector_size = ( power_of_two == 0 ) ?
1 << static_cast(std::ceil(std::log(list.size()) / std::log(2))) : power_of_two;
std::vector> padded_vector(padded_vector_size, std::complex(0.0, 0.0));
@@ -134,10 +110,9 @@ void fft(std::vector>& deconvolution1D, std::vector t = multiply(
- std::complex(std::cos(theta), std::sin(theta)), result[j + step + start]);
- deconvolution1D[( j / 2 ) + start] = add(result[j + start], t);
- deconvolution1D[( ( j + power_of_two ) / 2 ) + start] = subtract(result[j + start], t);
+ std::complex t = std::complex(std::cos(theta), std::sin(theta)) * result[j + step + start];
+ deconvolution1D[( j / 2 ) + start] = result[j + start] + t;
+ deconvolution1D[( ( j + power_of_two ) / 2 ) + start] = result[j + start] - t;
}
}
}
@@ -155,9 +130,9 @@ std::vector deconvolution(const std::vector& convolved, const
const int32_t& convolved_row_size, const int32_t& remain_size) {
int32_t power_of_two = 0;
- Return_Value convoluted_result = padAndComplexify(convolved, power_of_two);
+ Return_Value convoluted_result = pad_and_complexify(convolved, power_of_two);
std::vector> convoluted_padded = convoluted_result.list;
- Return_Value remove_result = padAndComplexify(remove, convoluted_result.power_of_two);
+ Return_Value remove_result = pad_and_complexify(remove, convoluted_result.power_of_two);
std::vector> remove_padded = remove_result.list;
power_of_two = remove_result.power_of_two;
@@ -165,7 +140,7 @@ std::vector deconvolution(const std::vector& convolved, const
fft(remove_padded, power_of_two);
std::vector> quotient(power_of_two, std::complex(0.0, 0.0));
for ( int32_t i = 0; i < power_of_two; ++i ) {
- quotient[i] = divide(convoluted_padded[i], remove_padded[i]);
+ quotient[i] = convoluted_padded[i] / remove_padded[i];
}
fft(quotient, power_of_two);
@@ -178,8 +153,8 @@ std::vector deconvolution(const std::vector& convolved, const
std::vector remain_vector(remain_size, 0);
int32_t i = 0;
while ( i > remove_size - convolved_size - convolved_row_size ) {
- remain_vector[-i] = std::lround(
- divide(quotient[( i + power_of_two ) % power_of_two], 32.0).real());
+ remain_vector[-i] = std::lround((
+ quotient[( i + power_of_two ) % power_of_two] / std::complex(32.0, 0.0)).real());
i -= 1;
}
return remain_vector;
diff --git a/Task/Delegates/EMal/delegates.emal b/Task/Delegates/EMal/delegates.emal
new file mode 100644
index 0000000000..fbe738a0a4
--- /dev/null
+++ b/Task/Delegates/EMal/delegates.emal
@@ -0,0 +1,25 @@
+type Thingable
+interface
+ fun thing ← text by block do end
+end
+type Delegate implements Thingable
+model
+ fun thing ← text by block
+ return "delegate implementation"
+ end
+end
+type Delegator
+model
+ Thingable delegate
+ fun operation ← <|when(me.delegate æ null, "default implementation", me.delegate.thing())
+end
+fun byDelegate ← Delegator by Thingable delegate
+ var delegator ← Delegator()
+ delegator.delegate ← delegate
+ return delegator
+end
+type Main
+Delegator a ← Delegator()
+writeLine(a.operation())
+Delegator b ← Delegator.byDelegate(Delegate())
+writeLine(b.operation())
diff --git a/Task/Descending-primes/Scala/descending-primes.scala b/Task/Descending-primes/Scala/descending-primes.scala
new file mode 100644
index 0000000000..cad06bbd50
--- /dev/null
+++ b/Task/Descending-primes/Scala/descending-primes.scala
@@ -0,0 +1,42 @@
+def isPrime(n: Long): Boolean = {
+ @annotation.tailrec
+ def hasDivisor(f: Long): Boolean =
+ if (f * f > n) false
+ else if (n % f == 0 || n % (f + 2) == 0) true
+ else hasDivisor(f + 6)
+
+ if (n < 2) false
+ else if (n == 2 || n == 3) true
+ else if (n % 2 == 0 || n % 3 == 0) false
+ else {
+ !hasDivisor(5)
+ }
+}
+
+def descendingPrimes(): Seq[Int] = {
+ val digits = Seq(9, 8, 7, 6, 5, 4, 3, 2, 1)
+
+ val (_, primes) = digits.foldLeft((Seq(0), Seq.empty[Int])) { case ((candidates, primes), digit) =>
+ val newCandidates = candidates.map(_ * 10 + digit)
+ val newPrimes = primes ++ newCandidates.filter(isPrime)
+ (candidates ++ newCandidates, newPrimes)
+ }
+
+ primes.sorted
+}
+
+@main def main(): Unit = {
+ def test(): Unit = {
+ val primes = descendingPrimes()
+
+ val maxDigits = primes.map(_.toString.length).max
+ val columnsPerLine = 8
+ val groupedPrimes = primes.grouped(columnsPerLine)
+ groupedPrimes.foreach { group =>
+ val formattedGroup = group.map(p => String.format(s"%${maxDigits}d", Int.box(p))).mkString(" ")
+ println(formattedGroup)
+ }
+ }
+
+ test()
+}
diff --git a/Task/Determinant-and-permanent/00-TASK.txt b/Task/Determinant-and-permanent/00-TASK.txt
index 7359865431..cce4a54788 100644
--- a/Task/Determinant-and-permanent/00-TASK.txt
+++ b/Task/Determinant-and-permanent/00-TASK.txt
@@ -8,7 +8,6 @@ In both cases the sum is over the permutations of the permut
More efficient algorithms for the determinant are known: [[LU decomposition]], see for example [[wp:LU decomposition#Computing the determinant]]. Efficient methods for calculating the permanent are not known.
-
;Related task:
* [[Permutations by swapping]]
diff --git a/Task/Determinant-and-permanent/ALGOL-68/determinant-and-permanent.alg b/Task/Determinant-and-permanent/ALGOL-68/determinant-and-permanent.alg
new file mode 100644
index 0000000000..c25b5c3420
--- /dev/null
+++ b/Task/Determinant-and-permanent/ALGOL-68/determinant-and-permanent.alg
@@ -0,0 +1,84 @@
+BEGIN # matrix determinant and permanent #
+ # - translated from the Phix sample, via EasyLang #
+
+ MODE NUMBER = REAL; # type of matrix elements to be handled #
+ # adjust to suit, if necessary #
+
+ PROC minor = ( [,]NUMBER a, INT x, y )[,]NUMBER:
+ BEGIN
+ [ 1 LWB a : 1 UPB a - 1, 2 LWB a : 2 UPB a - 1 ]NUMBER r;
+ FOR i FROM 1 LWB a TO 1 UPB a - 1 DO
+ FOR j FROM 2 LWB a TO 2 UPB a - 1 DO
+ r[ i, j ] := a[ i + ABS ( i >= x ), j + ABS ( j >= y ) ]
+ OD
+ OD;
+ r
+ END # minor # ;
+
+ PROC det = ( [,]NUMBER a )NUMBER:
+ IF 1 UPB a = 1 LWB a THEN # only one NUMBER #
+ a[ 1 LWB a, 2 LWB a ]
+ ELSE
+ INT sgn := 1;
+ NUMBER res := 0;
+ FOR i FROM 2 LWB a TO 2 UPB a DO
+ res +:= sgn * a[ 1 LWB a, i ] * det( minor( a, 1 LWB a, i ) );
+ sgn := - sgn
+ OD;
+ res
+ FI # det # ;
+
+ PROC perm = ( [,]NUMBER a )NUMBER:
+ IF 1 UPB a = 1 LWB a THEN # only one NUMBER #
+ a[ 1 LWB a, 2 LWB a ]
+ ELSE
+ NUMBER res := 0;
+ FOR i FROM 2 LWB a TO 2 UPB a DO
+ res +:= a[ 1 LWB a, i ] * perm( minor( a, 1 LWB a, i ) )
+ OD;
+ res
+ FI # perm # ;
+
+ BEGIN # test cases #
+ PROC test det and perm = ( [,]NUMBER a )VOID:
+ print( ( whole( det( a ), -8 ), " ", whole( perm( a ), -8 ), newline ) );
+
+ test det and perm( ( ( 1, 2 )
+ , ( 3, 4 )
+ )
+ );
+ test det and perm( ( ( 2, 9, 4 )
+ , ( 7, 5, 3 )
+ , ( 6, 1, 8 )
+ ) );
+ test det and perm( ( ( -2, 2, -3 )
+ , ( -1, 1, 3 )
+ , ( 2, 0, -1 )
+ )
+ );
+ test det and perm( ( ( 1, 2, 3, 4 )
+ , ( 4, 5, 6, 7 )
+ , ( 7, 8, 9, 10 )
+ , ( 10, 11, 12, 13 )
+ )
+ );
+ test det and perm( ( ( 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 )
+ )
+ );
+ test det and perm( ( ( 5 ) ) );
+ test det and perm( ( ( 1, 0, 0 )
+ , ( 0, 1, 0 )
+ , ( 0, 0, 1 )
+ )
+ );
+ test det and perm( ( ( 0, 0, 1 )
+ , ( 0, 1, 0 )
+ , ( 1, 0, 0 )
+ )
+ )
+ END
+END
diff --git a/Task/Determinant-and-permanent/XPL0/determinant-and-permanent.xpl0 b/Task/Determinant-and-permanent/XPL0/determinant-and-permanent.xpl0
new file mode 100644
index 0000000000..74c60b83ae
--- /dev/null
+++ b/Task/Determinant-and-permanent/XPL0/determinant-and-permanent.xpl0
@@ -0,0 +1,48 @@
+func DetPerm(Det, A, N); \Return value of determinant or permanent of A, order N
+int Det, A, N;
+int B Sum, Term;
+int I, K, L;
+[if N = 1 then return A(0, 0);
+B:= Reserve((N-1)*4);
+Sum:= 0;
+for I:= 0 to N-1 do
+ [L:= 0;
+ for K:= 0 to N-1 do
+ if K # I then
+ [B(L):= @A(K, 1); L:= L+1];
+ Term:= A(I, 0) * DetPerm(Det, B, N-1);
+ if Det & I&1 then Term:= -Term;
+ Sum:= Sum + Term;
+ ];
+return Sum;
+];
+
+int Arrays, I;
+[Arrays:= [
+ [ [1, 2],
+ [3, 4] ],
+
+ [ [-2, 2, -3],
+ [-1, 1, 3],
+ [ 2, 0, -1] ],
+
+ [ [ 1, 2, 3, 4],
+ [ 4, 5, 6, 7],
+ [ 7, 8, 9, 10],
+ [10, 11, 12, 13] ],
+
+ [ [ 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] ]
+ ];
+for I:= 0 to 3 do
+ [Text(0, "Determinant: ");
+ IntOut(0, DetPerm(true, Arrays(I), I+2));
+ CrLf(0);
+ Text(0, "Permanent : ");
+ IntOut(0, DetPerm(false, Arrays(I), I+2));
+ CrLf(0); CrLf(0);
+ ];
+]
diff --git a/Task/Determine-if-a-string-has-all-the-same-characters/C/determine-if-a-string-has-all-the-same-characters-1.c b/Task/Determine-if-a-string-has-all-the-same-characters/C/determine-if-a-string-has-all-the-same-characters-1.c
deleted file mode 100644
index 19fdbf57c8..0000000000
--- a/Task/Determine-if-a-string-has-all-the-same-characters/C/determine-if-a-string-has-all-the-same-characters-1.c
+++ /dev/null
@@ -1,33 +0,0 @@
-#include
-#include
-
-int main(int argc,char** argv)
-{
- int i,len;
- char reference;
-
- if(argc>2){
- printf("Usage : %s \n",argv[0]);
- return 0;
- }
-
- if(argc==1||strlen(argv[1])==1){
- printf("Input string : \"%s\"\nLength : %d\nAll characters are identical.\n",argc==1?"":argv[1],argc==1?0:(int)strlen(argv[1]));
- return 0;
- }
-
- reference = argv[1][0];
- len = strlen(argv[1]);
-
- for(i=1;i
-#include
-#include
-
-/*
- * The wide character version of the program is compiled if WIDE_CHAR is defined
- */
-#define WIDE_CHAR
-
-#ifdef WIDE_CHAR
-#define CHAR wchar_t
-#else
-#define CHAR char
-#endif
-
-/**
- * Find a character different from the preceding characters in the given string.
- *
- * @param s the given string, NULL terminated.
- *
- * @return the pointer to the occurence of the different character
- * or a pointer to NULL if all characters in the string
- * are exactly the same.
- *
- * @notice This function return a pointer to NULL also for empty strings.
- * Returning NULL-or-CHAR would not enable to compute the position
- * of the non-matching character.
- *
- * @warning This function compare characters (single-bytes, unicode etc.).
- * Therefore this is not designed to compare bytes. The NULL character
- * is always treated as the end-of-string marker, thus this function
- * cannot be used to scan strings with NULL character inside string,
- * for an example "aaa\0aaa\0\0".
- */
-const CHAR* find_different_char(const CHAR* s)
-{
- /* The code just below is almost the same regardles
- char or wchar_t is used. */
-
- const CHAR c = *s;
- while (*s && c == *s)
- {
- s++;
- }
- return s;
-}
-
-/**
- * Apply find_different_char function to a given string and output the raport.
- *
- * @param s the given NULL terminated string.
- */
-void report_different_char(const CHAR* s)
-{
-#ifdef WIDE_CHAR
- wprintf(L"\n");
- wprintf(L"string: \"%s\"\n", s);
- wprintf(L"length: %d\n", wcslen(s));
- const CHAR* d = find_different_char(s);
- if (d)
- {
- /*
- * We have got the famous pointers arithmetics and we can compute
- * difference of pointers pointing to the same array.
- */
- wprintf(L"character '%wc' (%#x) at %d\n", *d, *d, (int)(d - s));
- }
- else
- {
- wprintf(L"all characters are the same\n");
- }
- wprintf(L"\n");
-#else
- putchar('\n');
- printf("string: \"%s\"\n", s);
- printf("length: %d\n", strlen(s));
- const CHAR* d = find_different_char(s);
- if (d)
- {
- /*
- * We have got the famous pointers arithmetics and we can compute
- * difference of pointers pointing to the same array.
- */
- printf("character '%c' (%#x) at %d\n", *d, *d, (int)(d - s));
- }
- else
- {
- printf("all characters are the same\n");
- }
- putchar('\n');
-#endif
-}
-
-/* There is a wmain function as an entry point when argv[] points to wchar_t */
-
-#ifdef WIDE_CHAR
-int wmain(int argc, wchar_t* argv[])
-#else
-int main(int argc, char* argv[])
-#endif
-{
- if (argc < 2)
- {
- report_different_char(L"");
- report_different_char(L" ");
- report_different_char(L"2");
- report_different_char(L"333");
- report_different_char(L".55");
- report_different_char(L"tttTTT");
- report_different_char(L"4444 444k");
- }
- else
- {
- report_different_char(argv[1]);
- }
-
- return EXIT_SUCCESS;
-}
diff --git a/Task/Determine-if-a-string-has-all-the-same-characters/C/determine-if-a-string-has-all-the-same-characters.c b/Task/Determine-if-a-string-has-all-the-same-characters/C/determine-if-a-string-has-all-the-same-characters.c
new file mode 100644
index 0000000000..5517b124d6
--- /dev/null
+++ b/Task/Determine-if-a-string-has-all-the-same-characters/C/determine-if-a-string-has-all-the-same-characters.c
@@ -0,0 +1,37 @@
+#include
+#include
+#include
+
+void
+allCharsSame(const char *s)
+{
+ const char *p;
+ ptrdiff_t offs;
+
+ printf("Input: \"%s\", length = %ld\n", s, strlen(s));
+
+ for (p = s; *p; p++) {
+ if (p[1] && p[0] != p[1]) {
+ offs = &p[1] - s;
+ /* +8 to skip past 'Input: "' */
+ printf("%-*s^\n", (int)offs+8, "");
+ printf("Difference at position %ld: '%c' (%#02x) != '%c' (%#02x)\n",
+ offs, p[0], p[0], p[1], p[1]);
+ return;
+ }
+ }
+ printf("All characters are identical\n");
+}
+
+int
+main(void)
+{
+ allCharsSame("");
+ allCharsSame(" ");
+ allCharsSame("2");
+ allCharsSame("333");
+ allCharsSame(".55");
+ allCharsSame("tttTTT");
+ allCharsSame("4444 444k");
+ return 0;
+}
diff --git a/Task/Determine-if-a-string-has-all-unique-characters/C/determine-if-a-string-has-all-unique-characters.c b/Task/Determine-if-a-string-has-all-unique-characters/C/determine-if-a-string-has-all-unique-characters.c
index 31f2fa664f..51b8cdd0b7 100644
--- a/Task/Determine-if-a-string-has-all-unique-characters/C/determine-if-a-string-has-all-unique-characters.c
+++ b/Task/Determine-if-a-string-has-all-unique-characters/C/determine-if-a-string-has-all-unique-characters.c
@@ -1,128 +1,40 @@
-#include
-#include
-#include
-#include
+#include
+#include
+#include
-typedef struct positionList{
- int position;
- struct positionList *next;
-}positionList;
-
-typedef struct letterList{
- char letter;
- int repititions;
- positionList* positions;
- struct letterList *next;
-}letterList;
-
-letterList* letterSet;
-bool duplicatesFound = false;
-
-void checkAndUpdateLetterList(char c,int pos){
- bool letterOccurs = false;
- letterList *letterIterator,*newLetter;
- positionList *positionIterator,*newPosition;
-
- if(letterSet==NULL){
- letterSet = (letterList*)malloc(sizeof(letterList));
- letterSet->letter = c;
- letterSet->repititions = 0;
-
- letterSet->positions = (positionList*)malloc(sizeof(positionList));
- letterSet->positions->position = pos;
- letterSet->positions->next = NULL;
-
- letterSet->next = NULL;
- }
-
- else{
- letterIterator = letterSet;
-
- while(letterIterator!=NULL){
- if(letterIterator->letter==c){
- letterOccurs = true;
- duplicatesFound = true;
-
- letterIterator->repititions++;
- positionIterator = letterIterator->positions;
-
- while(positionIterator->next!=NULL)
- positionIterator = positionIterator->next;
-
- newPosition = (positionList*)malloc(sizeof(positionList));
- newPosition->position = pos;
- newPosition->next = NULL;
-
- positionIterator->next = newPosition;
- }
- if(letterOccurs==false && letterIterator->next==NULL)
- break;
- else
- letterIterator = letterIterator->next;
- }
-
- if(letterOccurs==false){
- newLetter = (letterList*)malloc(sizeof(letterList));
- newLetter->letter = c;
-
- newLetter->repititions = 0;
-
- newLetter->positions = (positionList*)malloc(sizeof(positionList));
- newLetter->positions->position = pos;
- newLetter->positions->next = NULL;
-
- newLetter->next = NULL;
-
- letterIterator->next = newLetter;
- }
- }
+/*
+* return -1 if s has no repeated characters, otherwise the array
+* index where a duplicated character first reappears
+*/
+int uniquechars(char *s) {
+ int i, j, slen;
+ slen = strlen(s);
+ if (slen < 2) return -1;
+ for (i = 0; i < (slen - 1); i++)
+ for (j = i + 1; j < slen; j++)
+ if (s[i] == s[j]) return j;
+ return -1;
}
-void printLetterList(){
- positionList* positionIterator;
- letterList* letterIterator = letterSet;
-
- while(letterIterator!=NULL){
- if(letterIterator->repititions>0){
- printf("\n'%c' (0x%x) at positions :",letterIterator->letter,letterIterator->letter);
-
- positionIterator = letterIterator->positions;
-
- while(positionIterator!=NULL){
- printf("%3d",positionIterator->position + 1);
- positionIterator = positionIterator->next;
- }
- }
-
- letterIterator = letterIterator->next;
- }
- printf("\n");
+void report(char *s) {
+ int pos, first;
+ pos = uniquechars(s);
+ if (pos == -1)
+ printf("\"%s\" (length = %d) has no duplicate characters\n", s, strlen(s));
+ else {
+ printf("\"%s\" (length = %d) has duplicate characters:\n", s, strlen(s));
+ /* find first instance of duplicated ch in s */
+ first = (int) (strchr(s, s[pos]) - s);
+ printf(" '%c' (= %2Xh) appears at positions %d and %d\n",
+ s[pos], s[pos], first+1, pos+1);
+ }
}
-int main(int argc,char** argv)
-{
- int i,len;
-
- if(argc>2){
- printf("Usage : %s \n",argv[0]);
- return 0;
- }
-
- if(argc==1||strlen(argv[1])==1){
- printf("\"%s\" - Length %d - Contains only unique characters.\n",argc==1?"":argv[1],argc==1?0:1);
- return 0;
- }
-
- len = strlen(argv[1]);
-
- for(i=0;i 0
+ dr = dr + n mod(10)
+ n = int(n / 10)
+ wend
+
+ ap = ap + 1
+ n = dr
+ until dr < 10
+
+end fn = dr
+
+
+long a(2)
+a(0) = 627615 : a(1) = 39390 : a(2) = 588225
+short i
+for i = 0 to 2
+ dr = fn digitalRoot(a(i))
+ print a(i), "Additive persistence = ", ap, "Digital root = ", dr
+next i
+
+handleevents
diff --git a/Task/Dijkstras-algorithm/FreeBASIC/dijkstras-algorithm.basic b/Task/Dijkstras-algorithm/FreeBASIC/dijkstras-algorithm.basic
new file mode 100644
index 0000000000..41e56c1e89
--- /dev/null
+++ b/Task/Dijkstras-algorithm/FreeBASIC/dijkstras-algorithm.basic
@@ -0,0 +1,140 @@
+Const INFINITY As Integer = &h7FFFFFFF
+
+Type Edge
+ src As String * 1
+ dst As String * 1
+ cost As Integer
+End Type
+
+Type Vertex
+ nom As String * 1
+ dist As Integer
+ prev As String * 1
+End Type
+
+Type Graph
+ edges(100) As Edge
+ edgeCount As Integer
+ verts(100) As Vertex
+ vertCount As Integer
+End Type
+
+Function createGraph(edges() As Edge, cnt As Integer) As Graph
+ Dim As Graph g
+ Dim As String names(100)
+ Dim As Integer i, j, nCount = 0
+
+ g.edgeCount = cnt
+
+ ' Copy edges and collect unique vertices
+ For i = 0 To cnt - 1
+ g.edges(i) = edges(i)
+
+ ' Check source vertex
+ Dim As Boolean found = False
+ For j = 0 To nCount - 1
+ If names(j) = edges(i).src Then
+ found = True
+ Exit For
+ End If
+ Next
+ If Not found Then
+ names(nCount) = edges(i).src
+ nCount += 1
+ End If
+
+ ' Check destination vertex
+ found = False
+ For j = 0 To nCount - 1
+ If names(j) = edges(i).dst Then
+ found = True
+ Exit For
+ End If
+ Next
+ If Not found Then
+ names(nCount) = edges(i).dst
+ nCount += 1
+ End If
+ Next
+
+ ' Initialize vertices
+ g.vertCount = nCount
+ For i = 0 To nCount - 1
+ With g.verts(i)
+ .nom = names(i)
+ .dist = INFINITY
+ .prev = names(i)
+ End With
+ Next
+
+ Return g
+End Function
+
+Function findVertex(g As Graph, nombre As String) As Integer
+ For i As Integer = 0 To g.vertCount - 1
+ If g.verts(i).nom = nombre Then Return i
+ Next
+ Return -1
+End Function
+
+Function dijkstraPath(g As Graph, source As String, dest As String) As Integer
+ Dim As Integer changed, i, srcIdx, dstIdx, newDist, destIdx
+ srcIdx = findVertex(g, source)
+ If srcIdx >= 0 Then g.verts(srcIdx).dist = 0
+
+ Do
+ changed = 0
+ For i = 0 To g.edgeCount - 1
+ With g.edges(i)
+ srcIdx = findVertex(g, .src)
+ dstIdx = findVertex(g, .dst)
+
+ If srcIdx >= 0 Andalso g.verts(srcIdx).dist <> INFINITY Then
+ newDist = g.verts(srcIdx).dist + .cost
+ If newDist < g.verts(dstIdx).dist Then
+ g.verts(dstIdx).dist = newDist
+ g.verts(dstIdx).prev = .src
+ changed = 1
+ End If
+ End If
+ End With
+ Next
+ Loop While changed
+
+ destIdx = findVertex(g, dest)
+ Return Iif(destIdx >= 0, g.verts(destIdx).dist, INFINITY)
+End Function
+
+Function getPath(g As Graph, source As String, dest As String) As String
+ Dim As String path = "", current = dest
+ Dim As Integer idx, destIdx, cost
+
+ ' Build path backwards
+ While current <> source
+ idx = findVertex(g, current)
+ If idx >= 0 Then
+ path = " -> " & current & path
+ current = g.verts(idx).prev
+ End If
+ Wend
+
+ ' Get final cost
+ destIdx = findVertex(g, dest)
+ cost = Iif(destIdx >= 0, g.verts(destIdx).dist, INFINITY)
+
+ Return source & " " & dest & " : " & source & path & " cost : " & cost
+End Function
+
+' Test program
+Dim As Edge testGraph(8) => {_
+("a", "b", 7), ("a", "c", 9), ("a", "f", 14), _
+("b", "c", 10), ("b", "d", 15), ("c", "d", 11), _
+("c", "f", 2), ("d", "e", 6), ("e", "f", 9)}
+
+Dim As Graph g = createGraph(testGraph(), 9)
+Dim As String source = "a", dest = "e"
+
+dijkstraPath(g, source, dest)
+Print getPath(g, source, dest)
+
+Sleep
diff --git a/Task/Dijkstras-algorithm/M2000-Interpreter/dijkstras-algorithm.m2000 b/Task/Dijkstras-algorithm/M2000-Interpreter/dijkstras-algorithm-1.m2000
similarity index 92%
rename from Task/Dijkstras-algorithm/M2000-Interpreter/dijkstras-algorithm.m2000
rename to Task/Dijkstras-algorithm/M2000-Interpreter/dijkstras-algorithm-1.m2000
index f04844c45f..b76ecc771a 100644
--- a/Task/Dijkstras-algorithm/M2000-Interpreter/dijkstras-algorithm.m2000
+++ b/Task/Dijkstras-algorithm/M2000-Interpreter/dijkstras-algorithm-1.m2000
@@ -4,18 +4,25 @@ Module Dijkstra`s_algorithm {
dim d(n)=val
=d()
}
+ FillList=lambda (n) -> {
+ m=list
+ for i=1 to n: append m, i: next
+ =m
+ }
+ // tree
term=("",0)
Edges=(("a", ("b",7),("c",9),("f",14)),("b",("c",10),("d",15)),("c",("d",11),("f",2)),("d",("e",6)),("e",("f", 9)),("f",term))
+ //
Document Doc$="Graph:"+{
}
ShowGraph()
Doc$="Paths"+{
}
Print "Paths"
- For from_here=0 to 5
+ For from_here=0 to Len(Edges)-1
pa=GetArr(len(Edges), -1)
d=GetArr(len(Edges), max_number)
- Inventory S=1,2,3,4,5,6
+ S=FillList(len(Edges))
return d, from_here:=0
RemoveMin=Lambda S, d, max_number-> {
ss=each(S)
diff --git a/Task/Dijkstras-algorithm/M2000-Interpreter/dijkstras-algorithm-2.m2000 b/Task/Dijkstras-algorithm/M2000-Interpreter/dijkstras-algorithm-2.m2000
new file mode 100644
index 0000000000..918a104194
--- /dev/null
+++ b/Task/Dijkstras-algorithm/M2000-Interpreter/dijkstras-algorithm-2.m2000
@@ -0,0 +1,132 @@
+Module Dijkstra`s_algorithm {
+ const max_number=1.E+306
+ GetArr=lambda (n, val)->{
+ dim d(n)=val
+ =d()
+ }
+ FillList=lambda (n) -> {
+ m=list
+ for i=1 to n : append m, i :next
+ =m
+ }
+ // tree
+ class node {
+ name$, val as long
+ remove {
+ created--
+ print "Node removed, left: "+created
+ }
+ class:
+ module node (.name$, .val) {
+ created++
+ print "New node, total: "+created
+ }
+ }
+ global long created
+ pNode = lambda ->{
+ ->node(![])
+ }
+ Class EdgeList {
+ object Node[0]
+ name$
+ class:
+ module EdgeList (.name$) {
+ n=0
+ while not empty
+ read .Node[n]
+ n++
+ end while
+ }
+ }
+ Node_A=EdgeList("a", pNode("b",7), pNode("c", 9), pNode("f",14) )
+ Node_B=EdgeList("b",pNode("c",10),pNode("d",15))
+ Node_C=EdgeList("c",pNode("d",11),pNode("f",2))
+ Node_D=EdgeList("d",pNode("e",6))
+ Node_E=EdgeList("e",pNode("f", 9))
+ Node_F=EdgeList("f",pNode())
+ Dim Edges(6)
+ Edges(0)=Node_A, Node_B, Node_C, Node_D, Node_E, Node_F
+ Document Doc$="Graph:"+{
+ }
+ ShowGraph()
+ Doc$="Paths"+{
+ }
+ Print "Paths"
+ For from_here=0 to Len(Edges())-1
+ pa=GetArr(len(Edges()), -1)
+ d=GetArr(len(Edges()), max_number)
+ S=FillList(len(Edges()))
+ return d, from_here:=0
+ RemoveMin=Lambda S, d, max_number-> {
+ ss=each(S)
+ min=max_number
+ p=0
+ while ss
+ val=d#val(eval(S,ss^)-1)
+ if min>val then let min=val : p=ss^
+ end while
+ =s(p!) ' use p as index not key
+ Delete S, eval(s,p)
+ }
+ Show_Distance_and_Path$=lambda$ d, pa, from_here, max_number (n) -> {
+ ret1$=chr$(from_here+asc("a"))+" to "+chr$(n+asc("a"))
+ if d#val(n) =max_number then =ret1$+ " No Path" :exit
+ let ret$="", mm=n, m=n
+ repeat
+ n=m
+ ret$+=chr$(asc("a")+n)
+ m=pa#val(n)
+ until from_here=n
+ =ret1$+format$("{0::-4} {1}",d#val(mm),strrev$(ret$))
+ }
+ while len(s)>0
+ u=RemoveMin()
+ rem Print u, chr$(u-1+asc("a"))
+ Relaxed()
+ end while
+ For i=0 to len(d)-1
+ line$=Show_Distance_and_Path$(i)
+ Print line$
+ doc$=line$+{
+ }
+ next
+ next
+ Clipboard Doc$
+ End
+ Sub Relaxed()
+ local vertex=Edges(u-1).node, i
+ local e=Len(vertex)-1, val
+ for i=0 to e
+ for vertex[i] {
+ if .name$<>"" then
+ val=Asc(.name$)-Asc("a")
+ if d#val(val)>.val+d#val(u-1) then return d, val:=.val+d#val(u-1) : Return Pa, val:=u-1
+ end if
+ }
+ next
+ end sub
+ Sub ShowGraph()
+ Print "Graph"
+ local i
+ for i=1 to len(Edges())
+ show_edges(i)
+ next
+ end sub
+ Sub show_edges(n)
+ n--
+ local line$, j
+ for Edges(n) {
+ for j=0 to len(.node)-1
+ Print .name$;
+ for .node[j] {
+ if ..name$>"" then
+ print "->"+..name$+" "+format$(" {0::-2}",..val)
+ else
+ print
+ end if
+ }
+ next
+ }
+ end sub
+}
+Dijkstra`s_algorithm
diff --git a/Task/Dijkstras-algorithm/PascalABC.NET/dijkstras-algorithm.pas b/Task/Dijkstras-algorithm/PascalABC.NET/dijkstras-algorithm.pas
new file mode 100644
index 0000000000..c77947a2fe
--- /dev/null
+++ b/Task/Dijkstras-algorithm/PascalABC.NET/dijkstras-algorithm.pas
@@ -0,0 +1,78 @@
+type
+ Edge = auto class
+ start, &end: char;
+ cost: real;
+ end;
+
+ Graph = auto class
+ edges: array of Edge;
+ vertices: HashSet;
+
+ constructor(params edges: array of (char, char, real));
+ begin
+ Self.edges := edges.Select(e -> new Edge(e[0], e[1], e[2])).ToArray;
+ Self.vertices := new HashSet(
+ Self.edges.Select(e -> e.start) + Self.edges.Select(e -> e.end)
+ );
+ end;
+
+ function Dijkstra(source, dest: char): sequence of char;
+ begin
+ assert(vertices.Contains(source));
+
+ var inf := real.MaxValue;
+ var dist := Dict(vertices.Select(v -> (v, inf)));
+ var previous := Dict(vertices.Select(v -> (v, ' ')));
+ dist[source] := 0;
+
+ var q := vertices.ToHashSet;
+ var neighbours := Dict(vertices.Select(v -> (v, new HashSet<(char, real)>)));
+
+ foreach var edge in edges do
+ begin
+ neighbours[edge.start].Add((edge.end, edge.cost));
+ neighbours[edge.end].Add((edge.start, edge.cost));
+ end;
+
+ while q.Count > 0 do
+ begin
+ var u := q.MinBy(v -> dist[v]);
+ q.Remove(u);
+
+ if (dist[u] = inf) or (u = dest) then
+ break;
+
+ foreach var (v, cost) in neighbours[u] do
+ begin
+ var alt := dist[u] + cost;
+ if alt < dist[v] then
+ begin
+ dist[v] := alt;
+ previous[v] := u;
+ end;
+ end;
+ end;
+
+ var s := new List;
+ var u := dest;
+
+ while previous[u] <> ' ' do
+ begin
+ s.Insert(0, u);
+ u := previous[u];
+ end;
+
+ s.Insert(0, u);
+ Result := s;
+ end;
+ end;
+
+begin
+ var gr := new Graph(
+ ('a', 'b', 7.0), ('a', 'c', 9.0), ('a', 'f', 14.0),
+ ('b', 'c', 10.0), ('b', 'd', 15.0), ('c', 'd', 11.0),
+ ('c', 'f', 2.0), ('d', 'e', 6.0), ('e', 'f', 9.0)
+ );
+
+ gr.Dijkstra('a', 'e').Println;
+end.
diff --git a/Task/Dinesmans-multiple-dwelling-problem/FutureBasic/dinesmans-multiple-dwelling-problem.basic b/Task/Dinesmans-multiple-dwelling-problem/FutureBasic/dinesmans-multiple-dwelling-problem.basic
new file mode 100644
index 0000000000..55f4064fdc
--- /dev/null
+++ b/Task/Dinesmans-multiple-dwelling-problem/FutureBasic/dinesmans-multiple-dwelling-problem.basic
@@ -0,0 +1,37 @@
+// Dinesmans multiple-dwelling problem
+//https://rosettacode.org/wiki/Dinesman%27s_multiple-dwelling_problem
+
+
+short Baker,Cooper,Fletcher,Miller,Smith
+short LoopCount
+
+FOR Baker = 0 TO 4
+ FOR Cooper = 0 TO 4
+ FOR Fletcher = 0 TO 4
+ FOR Miller = 0 TO 4
+ FOR Smith = 0 TO 4
+ IF Baker <> 4 && Cooper <> 0 && Miller <> Cooper
+ IF Fletcher <> 0 && Fletcher <> 4 && ABS(Smith-Fletcher)<>1 && ABS(Fletcher-Cooper)<>1
+ IF Baker<>Cooper and Baker<>Fletcher && Baker<>Miller and ¬
+ Baker<>Smith and Cooper<>Fletcher and Cooper<>Miller and ¬
+ Cooper<>Smith and Fletcher<>Miller and Fletcher<>Smith and ¬
+ Miller<>Smith
+
+ LoopCount ++
+ if LoopCount = 4
+ PRINT "Baker lives on floor " ; Baker + 1
+ PRINT "Cooper lives on floor " ; Cooper + 1
+ PRINT "Fletcher lives on floor " ; Fletcher + 1
+ PRINT "Miller lives on floor " ; Miller + 1
+ PRINT "Smith lives on floor " ; Smith + 1
+ end if
+ END IF
+ END IF
+ END IF
+ NEXT Smith
+ NEXT Miller
+ NEXT Fletcher
+ NEXT Cooper
+NEXT Baker
+
+handleevents
diff --git a/Task/Dining-philosophers/FreeBASIC/dining-philosophers.basic b/Task/Dining-philosophers/FreeBASIC/dining-philosophers.basic
new file mode 100644
index 0000000000..4909077304
--- /dev/null
+++ b/Task/Dining-philosophers/FreeBASIC/dining-philosophers.basic
@@ -0,0 +1,108 @@
+Const NUM_PHILOSOPHERS = 5
+Const HUNGER = 3
+Const THINK_TIME = 1000
+Const EAT_TIME = 1000
+
+Type Fork
+ mutex As Any Ptr
+ available As Boolean
+End Type
+
+Type Philosopher
+ nombre As String
+ leftFork As Fork Ptr
+ rightFork As Fork Ptr
+ hunger As Integer
+End Type
+
+Dim Shared As Philosopher philosophers(NUM_PHILOSOPHERS-1)
+Dim Shared As Fork forks(NUM_PHILOSOPHERS-1)
+Dim Shared As Any Ptr printMutex
+
+Function threadSafePrint(text As String) As Integer
+ Mutexlock(printMutex)
+ Print text
+ Mutexunlock(printMutex)
+ Return 0
+End Function
+
+Sub delay(ms As Integer)
+ Dim As Double t = Timer
+ While (Timer - t) * 1000 < ms
+ Sleep 1, 1
+ Wend
+End Sub
+
+Function philosopherThread(param As Any Ptr) As Any Ptr
+ Dim As Philosopher Ptr phil = param
+
+ threadSafePrint(phil->nombre + " seated")
+
+ While phil->hunger > 0
+ threadSafePrint(phil->nombre + " hungry")
+
+ Mutexlock(phil->leftFork->mutex)
+ Mutexlock(phil->rightFork->mutex)
+
+ threadSafePrint(phil->nombre + " eating")
+ delay(EAT_TIME)
+
+ Mutexunlock(phil->leftFork->mutex)
+ Mutexunlock(phil->rightFork->mutex)
+
+ threadSafePrint(phil->nombre + " thinking")
+ delay(THINK_TIME)
+
+ phil->hunger -= 1
+ Wend
+
+ threadSafePrint(phil->nombre + " satisfied")
+ threadSafePrint(phil->nombre + " left the table")
+
+ Return 0
+End Function
+
+' Main program
+Dim As Integer i
+Dim As String names(NUM_PHILOSOPHERS-1) = {"Aristotle", "Kant", "Spinoza", "Marx", "Russell"}
+Print "Table empty"
+
+printMutex = Mutexcreate()
+
+' Initialize forks
+For i = 0 To NUM_PHILOSOPHERS-1
+ forks(i).mutex = Mutexcreate()
+ forks(i).available = True
+Next
+
+' Initialize philosophers
+For i = 0 To NUM_PHILOSOPHERS-1
+ philosophers(i).nombre = names(i)
+ philosophers(i).hunger = HUNGER
+ philosophers(i).leftFork = @forks(i)
+ philosophers(i).rightFork = @forks((i + 1) Mod NUM_PHILOSOPHERS)
+Next
+
+' Make last philosopher left-handed
+Swap philosophers(NUM_PHILOSOPHERS-1).leftFork, philosophers(NUM_PHILOSOPHERS-1).rightFork
+
+' Create threads
+Dim As Any Ptr threads(NUM_PHILOSOPHERS-1)
+For i = 0 To NUM_PHILOSOPHERS-1
+ threads(i) = Threadcreate(Cast(Sub(As Any Ptr), @philosopherThread), @philosophers(i))
+Next
+
+' Wait for all threads
+For i = 0 To NUM_PHILOSOPHERS-1
+ Threadwait(threads(i))
+Next
+
+' Cleanup
+For i = 0 To NUM_PHILOSOPHERS-1
+ Mutexdestroy(forks(i).mutex)
+Next
+
+Mutexdestroy(printMutex)
+Print "Table empty"
+
+Sleep
diff --git a/Task/Display-a-linear-combination/XPL0/display-a-linear-combination.xpl0 b/Task/Display-a-linear-combination/XPL0/display-a-linear-combination.xpl0
new file mode 100644
index 0000000000..2186fb9b51
--- /dev/null
+++ b/Task/Display-a-linear-combination/XPL0/display-a-linear-combination.xpl0
@@ -0,0 +1,37 @@
+func LinearCombo(Combo, Len); \Display linear combination of Combo
+int Combo, Len;
+int Zero, N, I;
+[Zero:= true;
+for I:= 0 to Len-1 do
+ [N:= Combo(I);
+ if N # 0 then
+ [ if N < 0 and Zero then Text(0, "-")
+ else if N < 0 then Text(0, " - ")
+ else if not Zero then Text(0, " + ");
+ if abs(N) # 1 then
+ [IntOut(0, abs(N)); Text(0, "*")];
+ Text(0, "e("); IntOut(0, I+1); Text(0, ")");
+ Zero:= false;
+ ];
+ ];
+if Zero then Text(0, "0");
+CrLf(0);
+];
+
+int Combos, C;
+[Combos:= [
+ [1, 2, 3],
+ [0, 1, 2, 3],
+ [1, 0, 3, 4],
+ [1, 2, 0],
+ [0, 0, 0],
+ [0],
+ [1, 1, 1],
+ [-1, -1, -1],
+ [-1, -2, 0, -3],
+ [-1],
+ [0] \sentinel provides length of last item (=1)
+ ];
+for C:= 0 to 10-1 do
+ LinearCombo( Combos(C), (Combos(C+1)-Combos(C))/4 ); \4 = SizeOfInt
+]
diff --git a/Task/Display-an-outline-as-a-nested-table/ALGOL-68/display-an-outline-as-a-nested-table-1.alg b/Task/Display-an-outline-as-a-nested-table/ALGOL-68/display-an-outline-as-a-nested-table-1.alg
new file mode 100644
index 0000000000..4ac32f3482
--- /dev/null
+++ b/Task/Display-an-outline-as-a-nested-table/ALGOL-68/display-an-outline-as-a-nested-table-1.alg
@@ -0,0 +1,141 @@
+BEGIN # Show an outline as a wiki or HTML table #
+ MODE ONODE = STRUCT( STRING text, INT indent, REF ONODE next, child );
+ REF ONODE nil node = NIL;
+ OP LTRIM = ( STRING s )STRING: # returns s without leading spaces #
+ BEGIN
+ INT s pos := LWB s;
+ WHILE IF s pos > UPB s THEN FALSE ELSE s[ s pos ] = " " FI DO s pos +:= 1 OD;
+ IF s pos > UPB s THEN "" ELSE s[ s pos : ] FI
+ END # LTRIM # ;
+ OP INDENTOF = ( STRING s )INT: # returns count of leading spaces of s #
+ BEGIN
+ INT s pos := LWB s;
+ WHILE IF s pos > UPB s THEN FALSE ELSE s[ s pos ] = " " FI DO s pos +:= 1 OD;
+ s pos - LWB s
+ END # INDENTOF # ;
+
+ # count the total number of columns in tree #
+ OP COUNTCOLUMNS = ( REF ONODE tree )INT:
+ IF child OF tree IS nil node
+ THEN 1
+ ELSE INT count := 0;
+ REF ONODE next := child OF tree;
+ WHILE next ISNT nil node DO
+ count +:= COUNTCOLUMNS next;
+ next := next OF next
+ OD;
+ count
+ FI # COUNTCOLUMNS # ;
+
+ OP TOONODE = ( []STRING s )REF ONODE:
+ IF HEAP ONODE result;
+ LWB s > UPB s
+ THEN result := ( "", 0, nil node, nil node )
+ ELSE result := ( s[ LWB s ], INDENTOF s[ LWB s ], nil node, nil node );
+ [ 1 : ( UPB s - LWB s ) + 1 ]REF ONODE tstack;
+ FOR i TO UPB tstack DO tstack[ i ] := nil node OD;
+ INT s pos := LWB tstack;
+ tstack[ s pos ] := result;
+ FOR pos FROM LWB s + 1 TO UPB s DO
+ INT indent = INDENTOF s[ pos ];
+ WHILE indent < indent OF tstack[ s pos ] DO s pos -:= 1 OD;
+ HEAP ONODE next := ( s[ pos ], indent, nil node, nil node );
+ IF indent > indent OF tstack[ s pos ]
+ THEN child OF tstack[ s pos ] := next;
+ tstack[ s pos +:= 1 ] := next
+ ELSE IF next OF tstack[ s pos ] IS nil node
+ THEN next OF tstack[ s pos ] := next
+ FI;
+ tstack[ s pos ] := next
+ FI
+ OD;
+ result
+ FI # TOONODE # ;
+
+ PROC print tree table body = ( REF ONODE tree, STRING tr, rt, open td, close td, dt, empty td )VOID:
+ BEGIN
+ INT td max := 0; # find the maximum elements the rows #
+ REF ONODE next := tree;
+ WHILE next ISNT nil node DO
+ td max +:= COUNTCOLUMNS next;
+ next := next OF next
+ OD;
+ [ 1 : td max ]REF ONODE td; # get the elements of the first row #
+ td max := 0;
+ next := tree;
+ WHILE next ISNT nil node DO
+ td[ td max +:= 1 ] := next;
+ next := next OF next
+ OD;
+ BOOL more rows := TRUE; # generate the rows #
+ WHILE more rows DO
+ print( ( tr, newline ) ); # output the current row #
+ FOR td pos TO td max DO
+ REF ONODE element = td[ td pos ];
+ IF element IS nil node
+ THEN print( ( empty td ) )
+ ELSE INT span = COUNTCOLUMNS element;
+ print( ( open td ) );
+ IF span > 1 THEN print( ( " colspan=""", whole( span, 0 ), """" ) ) FI;
+ print( ( close td, LTRIM text OF element ) );
+ IF dt /= "" THEN print( ( "" ) ) FI;
+ print( ( newline ) )
+ FI
+ OD;
+ IF rt /= "" THEN print( ( rt, newline ) ) FI;
+ []REF ONODE prev = td[ 1 : td max ]; # replace td with the #
+ INT new max := 0; # ... child elements of the current row #
+ more rows := FALSE;
+ FOR td pos TO td max DO
+ next := IF prev[ td pos ] IS nil node
+ THEN nil node
+ ELSE child OF prev[ td pos ]
+ FI;
+ td[ new max +:= 1 ] := next;
+ IF next ISNT nil node THEN
+ more rows := TRUE;
+ WHILE ( next := next OF next ) ISNT nil node DO
+ td[ new max +:= 1 ] := next
+ OD
+ FI
+ OD;
+ td max := new max
+ OD
+ END # print tree table body # ;
+
+ # prints tree as an HTML table #
+ PROC print tree as html table = ( REF ONODE tree )VOID:
+ BEGIN
+ print( ( "", newline ) );
+ print tree table body( tree, "", " ", "", " ", " " );
+ print( ( "
", newline ) )
+ END # print tree as html table # ;
+
+ # prints tree as a wiki table b #
+ PROC print tree as wiki table = ( REF ONODE tree )VOID:
+ BEGIN
+ print( ( "{| class=""wikitable"" style=""text-align: center;""", newline ) );
+ print tree table body( tree, "|-", "", "| ", " | ", "", "| |" + REPR 10 );
+ print( ( "|}", newline ) )
+ END # print tree as wiki table # ;
+
+ BEGIN
+ REF ONODE ex tree
+ = TOONODE []STRING( "Display an outline as a nested table."
+ , " Parse the outline to a tree,"
+ , " measuring the indent of each line,"
+ , " translating the indentation to a nested structure,"
+ , " and padding the tree to even depth."
+ , " (happens during the output in this version)"
+ , " count the leaves descending from each node,"
+ , " defining the width of a leaf as 1,"
+ , " and the width of a parent node as a sum."
+ , " (The sum of the widths of its children)"
+ , " and write out a table with 'colspan' values"
+ , " either as a wiki table,"
+ , " or as HTML."
+ );
+ print tree as html table( ex tree );
+ print tree as wiki table( ex tree )
+ END
+END
diff --git a/Task/Display-an-outline-as-a-nested-table/ALGOL-68/display-an-outline-as-a-nested-table-2.alg b/Task/Display-an-outline-as-a-nested-table/ALGOL-68/display-an-outline-as-a-nested-table-2.alg
new file mode 100644
index 0000000000..6ff0caa928
--- /dev/null
+++ b/Task/Display-an-outline-as-a-nested-table/ALGOL-68/display-an-outline-as-a-nested-table-2.alg
@@ -0,0 +1,47 @@
+ # make all columns of tree have the same number of rows #
+ # tree is modified and also returned as the result #
+ OP STANDARDISE = ( REF ONODE tree )REF ONODE:
+ BEGIN
+ INT td max := 0; # find the maximum elements the rows #
+ REF ONODE next := tree;
+ WHILE next ISNT nil node DO
+ td max +:= COUNTCOLUMNS next;
+ next := next OF next
+ OD;
+ [ 1 : td max ]REF ONODE td; # get the elements of the first row #
+ td max := 0;
+ next := tree;
+ WHILE next ISNT nil node DO
+ td[ td max +:= 1 ] := next;
+ next := next OF next
+ OD;
+ WHILE BOOL more rows := FALSE; # balance the tree #
+ FOR td pos TO td max DO
+ REF ONODE element = td[ td pos ];
+ IF child OF element ISNT nil node
+ THEN more rows := TRUE
+ FI
+ OD;
+ more rows
+ DO FOR td pos TO td max DO # add "missing" child elements #
+ REF ONODE element = td[ td pos ];
+ IF child OF element IS nil node
+ THEN HEAP ONODE new child := ( "", 0, nil node, nil node );
+ child OF element := new child
+ FI
+ OD;
+ []REF ONODE prev = td[ 1 : td max ]; # replace td with the #
+ INT new max := 0; # ... child elements of the current row #
+ FOR td pos TO td max DO
+ next := child OF prev[ td pos ];
+ td[ new max +:= 1 ] := next;
+ IF next ISNT nil node THEN
+ WHILE ( next := next OF next ) ISNT nil node DO
+ td[ new max +:= 1 ] := next
+ OD
+ FI
+ OD;
+ td max := new max
+ OD;
+ tree
+ END # STANDARDISE # ;
diff --git a/Task/Distance-and-Bearing/FreeBASIC/distance-and-bearing.basic b/Task/Distance-and-Bearing/FreeBASIC/distance-and-bearing.basic
new file mode 100644
index 0000000000..701127456b
--- /dev/null
+++ b/Task/Distance-and-Bearing/FreeBASIC/distance-and-bearing.basic
@@ -0,0 +1,148 @@
+Type Airport
+ nombre As String
+ location As String
+ ICAO As String
+ dist As Double
+ bearing As Integer
+End Type
+
+#define MAX_AIRPORTS 21
+#define PI 3.1415926535897932
+
+Dim Shared db(MAX_AIRPORTS) As Airport
+Dim Shared DME As Double, TOHDG As Double
+
+Function DegToRad(degrees As Double) As Double
+ Return degrees * PI / 180
+End Function
+
+Function RoundIt(theNum As Double, theDec As Integer) As Double
+ Return Fix(theNum * (10 ^ theDec) + 0.5) / (10 ^ theDec)
+End Function
+
+Function DistanceGC(lat1 As Double, lon1 As Double, lat2 As Double, lon2 As Double) As Double
+ Dim As Double Dm, ER, dLat, dLon, a, c
+
+ ER = 6371.0 'Earth's mean radius in km
+ dLat = DegToRad(lat2) - DegToRad(lat1)
+ dLon = DegToRad(lon2) - DegToRad(lon1)
+ a = Sin(dLat / 2) * Sin(dLat / 2) + Cos(DegToRad(lat1)) * Cos(DegToRad(lat2)) * Sin(dLon / 2) * Sin(dLon / 2)
+ c = 2 * Atan2(Sqr(a), Sqr(1 - a))
+ Dm = ER * c / 1.852
+
+ Return Dm
+End Function
+
+Function Bearing(lat1 As Double, lon1 As Double, lat2 As Double, lon2 As Double) As Double
+ Dim As Double lat1Rad = DegToRad(lat1)
+ Dim As Double lat2Rad = DegToRad(lat2)
+ Dim As Double dLon = DegToRad(lon2 - lon1)
+ Dim As Double y = Sin(dLon) * Cos(lat2Rad)
+ Dim As Double x = Cos(lat1Rad) * Sin(lat2Rad) - Sin(lat1Rad) * Cos(lat2Rad) * Cos(dLon)
+
+ Return (Atan2(y, x) * 180/PI + 360) Mod 360
+End Function
+
+Sub Insert(ap As Airport)
+ Dim n As Integer = MAX_AIRPORTS - 1
+ If ap.dist >= db(n).dist Then Exit Sub
+ While ap.dist < db(n).dist Andalso n > 0
+ db(n + 1) = db(n)
+ n -= 1
+ Wend
+ db(n + 1) = ap
+End Sub
+
+Sub Test(lat2 As Double, lon2 As Double)
+ Static As Double lat1 = 51.514669, lon1 = 2.198581 'Rosetta coordinates
+ DME = DistanceGC(lat1, lon1, lat2, lon2)
+ DME = RoundIt(DME, 1)
+ TOHDG = Bearing(lat1, lon1, lat2, lon2)
+ TOHDG = RoundIt(TOHDG, 0)
+End Sub
+
+Function IsValidNumber(s As String) As Integer
+ Return (Val(s) <> 0 Or s = "0")
+End Function
+
+Function ReadAirportFile() As Integer
+ Dim As String linea, campo, c
+ Dim As Airport ap
+ Dim As Integer i, j, inQuotes
+
+ Open "Airport-data.csv" For Input As #1
+ If Err Then Print "Error opening file": Return 0
+
+ While Not Eof(1)
+ Line Input #1, linea
+ If Len(linea) = 0 Then Continue While
+
+ Dim fields(15) As String
+ i = 0
+ campo = ""
+ inQuotes = 0
+
+ For j = 1 To Len(linea)
+ c = Mid(linea, j, 1)
+ Select Case c
+ Case """"
+ inQuotes = Not inQuotes
+ Case ","
+ If Not inQuotes Then
+ If i < Ubound(fields) Then
+ fields(i) = campo
+ i += 1
+ campo = ""
+ End If
+ Else
+ campo &= c
+ End If
+ Case Else
+ If c <> """" Then campo &= c
+ End Select
+ Next
+
+ If i <= Ubound(fields) Then fields(i) = campo
+
+ If i >= 7 Then
+ If IsValidNumber(fields(6)) And IsValidNumber(fields(7)) Then
+ 'Process the fields
+ Test(Val(fields(6)), Val(fields(7)))
+ ap.nombre = Trim(fields(1))
+ ap.location = Trim(fields(2)) & ", " & Trim(fields(3))
+ ap.ICAO = Trim(fields(5))
+ ap.dist = DME
+ ap.bearing = TOHDG
+ Insert(ap)
+ End If
+ End If
+ Wend
+
+ Close #1
+ Return 1
+End Function
+
+'Main program
+Dim i As Integer
+
+'Initialize distances
+For i = 0 To MAX_AIRPORTS
+ db(i).dist = 99999
+Next
+
+If ReadAirportFile() Then
+ Print "AIRPORT/COUNTRY"; Tab(39); "ICAO"; Tab(46); "DISTANCE BEARING"
+ Print String(62, "-")
+
+ For i = 1 To MAX_AIRPORTS - 1
+ With db(i)
+ Print Left(.nombre & Space(38), 38)
+ Print Left(.location & Space(38), 38);
+ Print Left(.ICAO & Space(5), 5); Spc(6);
+ Print Using "##.# ###"; .dist; .bearing;
+ Print Chr(248); Chr(10)
+ End With
+ Next
+End If
+
+Sleep
diff --git a/Task/Diversity-prediction-theorem/PascalABC.NET/diversity-prediction-theorem.pas b/Task/Diversity-prediction-theorem/PascalABC.NET/diversity-prediction-theorem.pas
index cc2c4a9fd3..972e2e8c39 100644
--- a/Task/Diversity-prediction-theorem/PascalABC.NET/diversity-prediction-theorem.pas
+++ b/Task/Diversity-prediction-theorem/PascalABC.NET/diversity-prediction-theorem.pas
@@ -10,5 +10,5 @@ begin
WriteLn('diversity: ', AverageSquareDiff(average, predictions));
end;
-DiversityTheorem(49.0, |48.0, 47.0, 51.0|);
-DiversityTheorem(49.0, |48.0, 47.0, 51.0, 42.0|)
+DiversityTheorem(49.0, [48.0, 47.0, 51.0]);
+DiversityTheorem(49.0, [48.0, 47.0, 51.0, 42.0])
diff --git a/Task/Dominoes/Raku/dominoes.raku b/Task/Dominoes/Raku/dominoes.raku
new file mode 100644
index 0000000000..09e6b0f0e7
--- /dev/null
+++ b/Task/Dominoes/Raku/dominoes.raku
@@ -0,0 +1,85 @@
+sub domino (Str $s) { $s.comb.sort.join }
+
+sub solve ( UInt $rows, UInt $cols, @tab ) {
+ die unless @tab.elems == $rows*$cols;
+ die unless @tab.elems %% 2;
+
+ my @orientations = 'A' xx @tab.elems; # [A]vailable,[R]ight,[D]own,[L]eft,[U]p
+
+ my SetHash $hand .= new: map &domino, [X~] @tab.unique xx 2;
+
+ return gather {
+ my sub place_domino_at_first_available_after ( UInt $pos_last = 0 ) {
+ my $p1 = $pos_last + @orientations.skip($pos_last).first(:k, 'A');
+
+ for (False, $p1+1 , ),
+ (True , $p1+$cols, ) -> ($is_down, $p2, @two_letters) {
+
+ next if $p2 > @tab.end or (!$is_down && $p2 %% $cols); # Board boundaries.
+
+ my @two_cells := @orientations[$p1, $p2]; # Bind to candidate location
+
+ next if @two_cells !eqv ; # Both cells must be available for placement.
+
+ my $dom = domino( @tab[$p1, $p2].join );
+
+ $hand{$dom}-- or next; # Take domino from hand, iff present
+ @two_cells = @two_letters; # Assign placement
+
+ # Either the solution is complete, or we must recurse.
+ if !$hand { take @orientations.clone }
+ else { place_domino_at_first_available_after($p1) }
+
+ @two_cells = ; # Unassign placement
+ $hand{$dom}++; # Restore domino into hand
+ }
+ }
+ place_domino_at_first_available_after();
+ }
+}
+sub bonus ( UInt $rows, UInt $cols ) {
+ die "Both are odd, so no tiling possible" if $rows !%% 2 and $cols !%% 2;
+
+ my $half = $rows * $cols div 2;
+
+ my sub T ($N) { map { ( pi * $_/($N+1) ).cos² * 4 }, 1..($N/2).ceiling }
+
+ my $arrangements = [*] T($rows) X+ T($cols);
+ my $flips = 2 ** $half;
+ my $permutations = [*] 1 .. $half;
+ my $product = [*] ($arrangements, $flips, $permutations);
+ return :$arrangements, :$flips, :$permutations, :$product;
+}
+my @tests =
+ (7, 8, '05132231055052464303662006235126113002452143346664515414'),
+ (7, 8, '64220650162341432102355113505610426040114420536366525334'),
+ (3, 4, '001102221201'),
+;
+sub solution_works ( UInt $rows, UInt $cols, @tab, @sol --> Bool ) {
+ die unless @sol.all eq .any;
+ my BagHash $b .= new;
+ for @sol.keys -> $p1 {
+ given @sol[$p1] {
+ when 'L' { my $p2 = $p1+1; die unless @sol[$p2] eq 'R'; $b{ domino( @tab[$p1,$p2].join ) }++; }
+ when 'D' { my $p2 = $p1+$cols; die unless @sol[$p2] eq 'U'; $b{ domino( @tab[$p1,$p2].join ) }++; }
+ }
+ }
+ die unless $b.values.max == 1 and $b.elems == $rows * $cols / 2;
+ return True;
+}
+for @tests -> ( $rows, $cols, $flat_table ) {
+ my @solutions = solve($rows, $cols, $flat_table.comb);
+ say 'Solutions found: ', +@solutions;
+
+ # Confirm that every solution is valid.
+ solution_works($rows, $cols, $flat_table.comb, $_) or die for @solutions;
+
+ # Print first solution
+ say .join.trans( [] => [<╼ ╾ ╽ ╿>]) for @solutions[0].batch($cols);
+
+ if ++$ == 1 {
+ say 'Bonus:';
+ say .value.fmt("%45d "), .key.tclc for bonus($rows, $cols);
+ say '';
+ }
+}
diff --git a/Task/Doomsday-rule/Draco/doomsday-rule.draco b/Task/Doomsday-rule/Draco/doomsday-rule.draco
new file mode 100644
index 0000000000..73e8211a33
--- /dev/null
+++ b/Task/Doomsday-rule/Draco/doomsday-rule.draco
@@ -0,0 +1,50 @@
+type Date = struct {
+ word year;
+ byte month;
+ byte day;
+};
+
+proc leap_year(word y) bool:
+ y%4 = 0 and (y%100 /= 0 or y % 400 = 0)
+corp
+
+proc weekday(Date date) *char:
+ [12]byte leapdoom = (4,1,7,4,2,6,4,1,5,3,7,5);
+ [12]byte normdoom = (3,7,7,4,2,6,4,1,5,3,7,5);
+ word c, r, s, t, c_anchor, doom, anchor;
+
+ c := date.year / 100;
+ r := date.year % 100;
+ s := r / 12;
+ t := r % 12;
+
+ c_anchor := (5 * (c % 4) + 2) % 7;
+ doom := (s + t + (t/4) + c_anchor) % 7;
+ anchor := if leap_year(date.year)
+ then leapdoom[date.month-1]
+ else normdoom[date.month-1]
+ fi;
+
+ case (doom+date.day-anchor+7)%7
+ incase 0: "Sunday"
+ incase 1: "Monday"
+ incase 2: "Tuesday"
+ incase 3: "Wednesday"
+ incase 4: "Thursday"
+ incase 5: "Friday"
+ incase 6: "Saturday"
+ esac
+corp
+
+proc main() void:
+ [7]Date dates = (
+ (1800,1,6), (1875,3,29), (1915,12,7), (1970,12,23), (2043,5,14),
+ (2077,2,12), (2101,4,2)
+ );
+
+ word d;
+ for d from 0 upto 6 do
+ writeln(dates[d].month:2, '/', dates[d].day:2, '/', dates[d].year:4,
+ ": ", weekday(dates[d]))
+ od
+corp
diff --git a/Task/Doomsday-rule/M2000-Interpreter/doomsday-rule.m2000 b/Task/Doomsday-rule/M2000-Interpreter/doomsday-rule.m2000
new file mode 100644
index 0000000000..bc2bab76ac
--- /dev/null
+++ b/Task/Doomsday-rule/M2000-Interpreter/doomsday-rule.m2000
@@ -0,0 +1,60 @@
+' MAKE USING("FORMAT STRING", PAR1, PAR2, ...PARN)
+' WE USE READ V TO READ MORE PARAMETERS.
+FUNCTION USING(A$) {
+ VARIANT V : LONG D, S, E, I=1: S$=""
+ WHILE I<=LEN(A$)
+ IF S THEN
+ IF MID$(A$,I,1)<>"#" THEN
+ IF MID$(A$,I,1)="." THEN D=I ELSE E=I
+ END IF
+ ELSE
+ IF MID$(A$,I,1)="#" THEN S=I
+ END IF
+ IF S AND E THEN
+ IF S>1 THEN S$+=LEFT$(A$, S-1)
+ A$=MID$(A$, E)
+ G()
+ S=0:E=0:D=0
+ I=1
+ END IF
+ I++
+ END WHILE
+ IF S THEN
+ IF S>1 THEN S$+=LEFT$(A$, S-1):E=I-S+1: S=1 ELSE E=I
+ G()
+ =S$
+ ELSE
+ =S$+A$
+ END IF
+ SUB G()
+ IF ISNUM THEN
+ READ V
+ IF D>0 THEN
+ S$+=STR$(V, STRING$("#",E-D-1)+"0."+STRING$("0",D-S+1))
+ ELSE
+ S$+=STR$(V, STRING$("0",E-S-1)+"0")
+ END IF
+ ELSE
+ V=""
+ READ V
+ S$+=LEFT$(V+STRING$(" ", E-S), E-S)
+ END IF
+ END SUB
+}
+05 FLUSH : GOSUB 110
+10 DIM D$(1 TO 7): FOR I=1 TO 7: READ D$(I): NEXT I
+20 DIM D(1 TO 12, 0 TO 1): FOR I=0 TO 1: FOR J=1 TO 12: READ D(J, I): NEXT J : NEXT I
+30 READ Y: IF Y=0 THEN BREAK ELSE READ M,D
+40 PRINT USING("##/##/#### ", M, D, Y);
+50 C=Y DIV 100: R=Y MOD 100
+60 S=R DIV 12: T=R MOD 12
+70 A=(5*BINARY.AND(C, 3)+2) MOD 7
+80 B=(S+T+(T DIV 4)+A) MOD 7
+90 PRINT D$((B+D-D(M,-(Y MOD 4=0 AND (Y MOD 100<>0 OR Y MOD 400=0)))+7) MOD 7+1)
+100 GOTO 30
+110 DATA "Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"
+120 DATA 3,7,7,4,2,6,4,1,5,3,7,5
+130 DATA 4,1,7,4,2,6,4,1,5,3,7,5
+140 DATA 1800,1,6,1875,3,29,1915,12,7,1970,12,23
+150 DATA 2043,5,14,2077,2,12,2101,4,2,0
+160 RETURN
diff --git a/Task/Doomsday-rule/Miranda/doomsday-rule.miranda b/Task/Doomsday-rule/Miranda/doomsday-rule.miranda
new file mode 100644
index 0000000000..de3b570449
--- /dev/null
+++ b/Task/Doomsday-rule/Miranda/doomsday-rule.miranda
@@ -0,0 +1,29 @@
+main :: [sys_message]
+main = [Stdout (lay [showdate d ++ ": " ++ weekday d | d<-tests])]
+
+date ::= Date (num,num,num)
+
+showdate :: date->[char]
+showdate (Date (y,m,d)) = show m ++ "/" ++ show d ++ "/" ++ show y
+
+tests :: [date]
+tests = map Date [
+ (1800,1,6), (1875,3,29), (1915,12,7), (1970,12,23), (2043,5,14),
+ (2077,2,12), (2101,4,2)]
+
+weekday :: date->[char]
+weekday (Date (year,month,day))
+ = weekdays ! daynum
+ where weekdays = ["Sunday","Monday","Tuesday","Wednesday","Thursday",
+ "Friday","Saturday"]
+ doomtab = leapdoom, if leapyear
+ = normdoom, otherwise
+ leapdoom = [4,1,7,2,4,6,4,1,5,3,7,5]
+ normdoom = [3,7,7,4,2,6,4,1,5,3,7,5]
+ leapyear = year mod 4=0 & (year mod 100~=0 \/ year mod 400=0)
+ (c, r) = (year div 100, year mod 100)
+ (s, t) = (r div 12, r mod 12)
+ c_anchor = (5 * (c mod 4) + 2) mod 7
+ doom = (s + t + t div 4 + c_anchor) mod 7
+ anchor = doomtab ! (month - 1)
+ daynum = (doom + day - anchor + 7) mod 7
diff --git a/Task/Doomsday-rule/Quackery/doomsday-rule.quackery b/Task/Doomsday-rule/Quackery/doomsday-rule.quackery
new file mode 100644
index 0000000000..5dfa5b0e1d
--- /dev/null
+++ b/Task/Doomsday-rule/Quackery/doomsday-rule.quackery
@@ -0,0 +1,26 @@
+ [ dup 400 mod 0 = iff [ drop true ] done
+ dup 100 mod 0 = iff [ drop false ] done
+ 4 mod 0 = ] is leap ( y --> b )
+
+ [ dup 4 mod 5 *
+ over 100 mod 4 * +
+ swap 400 mod 6 * + 2 + 7 mod ] is doomsday ( y --> n )
+
+ [ leap iff [ ' [ table 0 4 1 ] ]
+ else [ ' [ table 0 3 7 ] ]
+ ' [ 7 4 2 6 4 1 5 3 7 5 ] join do ] is close ( m y --> n )
+
+ [ dup doomsday unrot close - + 7 mod ] is weekday ( d m y --> n )
+
+ [ [ table $ "Sunday" $ "Monday"
+ $ "Tuesday" $ "Wednesday" $ "Thursday"
+ $ "Friday" $ "Saturday" ] do echo$ ] is echoday ( d --> )
+
+ ' [ [ 6 1 1800 ]
+ [ 29 3 1875 ]
+ [ 7 12 1915 ]
+ [ 23 12 1970 ]
+ [ 14 5 2043 ]
+ [ 12 2 2077 ]
+ [ 2 4 2101 ] ]
+ witheach [ unpack weekday echoday cr ]
diff --git a/Task/Doomsday-rule/Refal/doomsday-rule.refal b/Task/Doomsday-rule/Refal/doomsday-rule.refal
new file mode 100644
index 0000000000..611e530466
--- /dev/null
+++ b/Task/Doomsday-rule/Refal/doomsday-rule.refal
@@ -0,0 +1,43 @@
+$ENTRY Go {
+ , (1800 1 6) (1875 3 29) (1915 12 7) (1970 12 23)
+ (2043 5 14) (2077 2 12) (2101 4 2): e.Tests
+ = ;
+};
+
+Test {
+ e.Test = >;
+};
+
+LeapYear {
+ s.Year = >
+ >
+ >>>;
+};
+
+Weekday {
+ s.Year s.Month s.Day,
+ 4 1 7 4 2 6 4 1 5 3 7 5: e.LeapDoom,
+ 3 7 7 4 2 6 4 1 5 3 7 5: e.NormDoom,
+ Sunday Monday Tuesday Wednesday Thursday Friday Saturday: e.Days,
+ : (s.C) s.R,
+ : (s.S) s.T,
+ >> 7>: s.CAn,
+ >>> 7>: s.Doom,
+ (e.LeapDoom) (e.NormDoom)>: (e.DoomTab),
+ - e.DoomTab>: e.Anchor,
+
e.Anchor>> 7>: s.Weekday
+ = - ;
+};
+
+Item {
+ 0 s.X e.XS = s.X;
+ s.N s.X e.XS =
- e.XS>;
+};
+
+If { True t.T t.F = t.T; False t.T t.F = t.F; };
+Eq { t.X t.X = True; t.X t.Y = False; };
+Or { True s.Y = True; False s.Y = s.Y; };
+And { False s.Y = False; True s.Y = s.Y; };
+Not { True = False; False = True; };
+Neq { t.X t.Y =
>; };
+Each { (e.F) = ; (e.F) (e.X) e.XS = ; };
diff --git a/Task/Doomsday-rule/SETL/doomsday-rule.setl b/Task/Doomsday-rule/SETL/doomsday-rule.setl
new file mode 100644
index 0000000000..cf225f497f
--- /dev/null
+++ b/Task/Doomsday-rule/SETL/doomsday-rule.setl
@@ -0,0 +1,29 @@
+program doomsday;
+ tests := [[1800,1,6], [1875,3,29], [1915,12,7], [1970,12,23],
+ [2043,5,14], [2077,2,12], [2101,4,2]];
+
+ loop for [year, month, day] in tests do
+ print(str day + "/" + str month + "/" + str year + ": " +
+ weekday(year, month, day));
+ end loop;
+
+ proc leap(y);
+ return y mod 4 = 0 and (y mod 100 /= 0 or y mod 400 = 0);
+ end proc;
+
+ proc weekday(year, month, day);
+ leapdoom := [4,1,7,4,2,6,4,1,5,3,7,5];
+ normdoom := [3,7,7,4,2,6,4,1,5,3,7,5];
+ weekdays := ["Sunday","Monday","Tuesday","Wednesday","Thursday",
+ "Friday","Saturday"];
+
+ c := year div 100;
+ r := year mod 100;
+ s := r div 12;
+ t := r mod 12;
+ c_anchor := (5 * (c mod 4) + 2) mod 7;
+ doom := (s + t + (t div 4) + c_anchor) mod 7;
+ anchor := if leap(year) then leapdoom else normdoom end(month);
+ return weekdays((doom+day-anchor+7) mod 7+1);
+ end proc;
+end program;
diff --git a/Task/Doomsday-rule/UNIX-Shell/doomsday-rule.sh b/Task/Doomsday-rule/UNIX-Shell/doomsday-rule.sh
index 10334c8be4..891530b914 100644
--- a/Task/Doomsday-rule/UNIX-Shell/doomsday-rule.sh
+++ b/Task/Doomsday-rule/UNIX-Shell/doomsday-rule.sh
@@ -5,14 +5,14 @@ day-of-the-week()
then
local -ra names=({Sun,Mon,Tues,Wednes,Thurs,Fri,Satur}day) doomsday=({37,41}7426415375)
local -i i c s t a b
- local -i {year,month,day}=${BASH_REMATCH[++i]}
+ local -i {y,m,d}=${BASH_REMATCH[++i]}
echo ${names[
- c=year/100,
- s=(year%100)/12,
- t=(year % 100) % 12,
+ c=y/100,
+ s=(y%100)/12,
+ t=(y % 100) % 12,
a=(5*(c%4)+2) % 7,
b=(s + t + (t / 4) + a ) % 7,
- (b + day - ${doomsday[(year%4 == 0) && ((year%100) || (year%400 == 0))]:month-1:1} + 7) % 7
+ (b + d - ${doomsday[(y%4 == 0) && ((y%100) || (y%400 == 0))]:m-1:1} + 7) % 7
]}
else return 1
fi
diff --git a/Task/Doomsday-rule/V-(Vlang)/doomsday-rule.v b/Task/Doomsday-rule/V-(Vlang)/doomsday-rule.v
index bc6194f84e..002a8b84fc 100644
--- a/Task/Doomsday-rule/V-(Vlang)/doomsday-rule.v
+++ b/Task/Doomsday-rule/V-(Vlang)/doomsday-rule.v
@@ -1,5 +1,4 @@
-const
-(
+const (
days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
first_days_common = [3, 7, 7, 4, 2, 6, 4, 1, 5, 3, 7, 5]
first_days_leap = [4, 1, 7, 4, 2, 6, 4, 1, 5, 3, 7, 5]
@@ -24,15 +23,11 @@ fn main() {
d = date[8..10].int()
a = anchor_day(y)
f = first_days_common[m]
- if is_leap_year(y) {
- f = first_days_leap[m]
- }
+ if is_leap_year(y) {f = first_days_leap[m]}
w = d - f
- if w < 0 {
- w = 7 + w
- }
+ if w < 0 {w = 7 + w}
dow = (a + w) % 7
- println('$date -> ${days[dow]}')
+ println("$date -> ${days[dow]}")
}
}
diff --git a/Task/Dot-product/Zig/dot-product.zig b/Task/Dot-product/Zig/dot-product.zig
index 82ecb11802..1118520c95 100644
--- a/Task/Dot-product/Zig/dot-product.zig
+++ b/Task/Dot-product/Zig/dot-product.zig
@@ -1,10 +1,9 @@
const std = @import("std");
-const Vector = std.meta.Vector;
pub fn main() !void {
- const a: Vector(3, i32) = [_]i32{1, 3, -5};
- const b: Vector(3, i32) = [_]i32{4, -2, -1};
- var dot: i32 = @reduce(.Add, a*b);
+ const a = @Vector(3, i32){ 1, 3, -5 };
+ const b = @Vector(3, i32){ 4, -2, -1 };
+ const dot: i32 = @reduce(.Add, a * b);
try std.io.getStdOut().writer().print("{d}\n", .{dot});
}
diff --git a/Task/Doubly-linked-list-Definition/FutureBasic/doubly-linked-list-definition.basic b/Task/Doubly-linked-list-Definition/FutureBasic/doubly-linked-list-definition.basic
new file mode 100644
index 0000000000..32155d51d0
--- /dev/null
+++ b/Task/Doubly-linked-list-Definition/FutureBasic/doubly-linked-list-definition.basic
@@ -0,0 +1,67 @@
+begin globals
+ str255 List(8) //create a new list of strings (List(0) not used
+end globals
+
+
+local fn ShowList(title As str255)
+ //display all elements from list of string
+ short j
+ Print title;
+ For j = 1 to 7
+ Print List(j); " ";
+ Next j
+ Print ""
+End fn
+
+
+/////////// MAIN PROGRAM ////////////
+
+Dim As str255 item //items to add to the list
+Dim As short i,j, c = 0
+
+//the list of data that will be added to the list
+data:
+Data "One", "Two", "Three", "Four", "Five", "Six", "EndOfData"
+
+Restore
+c = 0
+Do
+ Read item
+ If item <> "EndOfData" Then List(c) = item
+ c ++
+Until item = "EndOfData"
+
+str255 ListTMP(7)
+
+For j = 1 To 7
+ ListTMP(7-j) = List(j)
+Next j
+For j = 1 To 7
+ Swap List(j), ListTMP(j)
+Next j
+fn ShowList("Insertion at Head: ")
+
+for i = 1 to 7 : List(i) = "" : next i // clear list
+Restore
+c = 0
+Do
+ Read item //: c += 1
+ If item <> "EndOfData" Then List(c) = item
+ c ++
+Until item = "EndOfData"
+fn ShowList("Insertion at Tail: ")
+
+for i = 1 to 7 : List(i) = "" : next i // clear list
+Restore
+c = 0
+Do
+ Read item //: c += 1
+ If item <> "EndOfData" Then List(c) = item
+ c ++
+Until item = "EndOfData"
+
+Swap List(3), List(6)
+fn ShowList("Insertion in Middle: ")
+
+
+handleevents
diff --git a/Task/Dragon-curve/ALGOL-68/dragon-curve-4.alg b/Task/Dragon-curve/ALGOL-68/dragon-curve-4.alg
index 55d2235f9e..4d180563f7 100644
--- a/Task/Dragon-curve/ALGOL-68/dragon-curve-4.alg
+++ b/Task/Dragon-curve/ALGOL-68/dragon-curve-4.alg
@@ -53,7 +53,7 @@ BEGIN # Dragon Curve in SVG #
put( svg file, ( "'/>", newline, "", newline ) );
close( svg file )
- FI # sierpinski square # ;
+ FI # dragon curve # ;
dragon curve( "dragon.svg", 1200, 5, 12, 400, 200 )
diff --git a/Task/Dragon-curve/ASIC/dragon-curve.asic b/Task/Dragon-curve/ASIC/dragon-curve.asic
new file mode 100644
index 0000000000..5697f69b99
--- /dev/null
+++ b/Task/Dragon-curve/ASIC/dragon-curve.asic
@@ -0,0 +1,130 @@
+REM Dragon curve
+DIM S@(7)
+DIM C@(7)
+DIM R(27)
+REM SIN, COS in arrays for PI/4 multipl.
+DATA 0@, 0.70711@, 1@, 0.70711@, 0@, -0.70711@, -1@, -0.70711@
+DATA 1@, 0.70711@, 0@, -0.70711@, -1@, -0.70711@, 0@, 0.70711@
+Sqrt2@ = 1.41421@
+FOR I = 0 TO 7
+ READ S@(I)
+NEXT I
+FOR I = 0 TO 7
+ READ C@(I)
+NEXT I
+Level = 17
+Insize@ = 256
+REM Insize@ = 2^WHOLE_NUM looks fine
+X@ = 224
+Y@ = 124
+RotQPi = 0
+RQ = 1
+SCREEN 9
+GOSUB Dragon:
+LOCATE 20, 1
+PRINT "Press any key to exit."
+Loop:
+ X$=INKEY$
+ IF X$="" THEN Loop:
+SCREEN 0
+END
+
+Dragon:
+RotQPi = RotQPi MOD 8
+WHILE RotQPi < 0
+ RotQPi = RotQPi + 8
+WEND
+IF Level <= 1 THEN
+ YN@ = S@(RotQPi) * Insize@
+ YN@ = YN@ + Y@
+ XN@ = C@(RotQPi) * Insize@
+ XN@ = XN@ + X@
+ GOSUB DrawLine:
+ X@ = XN@
+ Y@ = YN@
+ELSE
+ Insize@ = Insize@ * Sqrt2@
+ Insize@ = Insize@ / 2@
+ RotQPi = RotQPi + RQ
+ RotQPi = RotQPi MOD 8
+ WHILE RotQPi < 0
+ RotQPi = RotQPi + 8
+ WEND
+ Level = Level - 1
+ R(Level) = RQ
+ RQ = 1
+ GOSUB Dragon:
+ RLevelM2 = R(Level) * 2
+ RotQPi = RotQPi - RLevelM2
+ RotQPi = RotQPi MOD 8
+ WHILE RotQPi < 0
+ RotQPi = RotQPi + 8
+ WEND
+ RQ = -1
+ GOSUB Dragon:
+ RQ = R(Level)
+ RotQPi = RotQPi + RQ
+ RotQPi = RotQPi MOD 8
+ WHILE RotQPi < 0
+ RotQPi = RotQPi + 8
+ WEND
+ Level = Level + 1
+ Insize@ = Insize@ * Sqrt2@
+ENDIF
+RETURN
+
+DrawLine:
+REM Draw a line from (X@, Y@) to (XN@, YN@)
+REM Coordinates decimal, but converted in PSET.
+DX@ = XN@ - X@
+DY@ = YN@ - Y@
+AbsDX@ = ABS(DX@)
+AbsDY@ = ABS(DY@)
+IF AbsDX@ <= AbsDY@ THEN
+ REM More vertical line
+ IF AbsDY@ <= 1@ THEN
+ REM The same pixel or neighboring ones, because AbsDX@ <= AbsDY@ <= 1.
+ PSET (Y@, X@), 10
+ PSET (YN@, XN@), 10
+ ELSE
+ REM There are pixels in between.
+ A@ = DX@ / DY@
+ IF YN@ >= Y@ THEN
+ D@ = 1@
+ ELSE
+ D@ = -1@
+ ENDIF
+ CoordY@ = Y@
+ WHILE CoordY@ <= YN@
+ CoordX@ = CoordY@ - Y@
+ CoordX@ = A@ * CoordX@
+ CoordX@ = X@ + CoordX@
+ PSET (CoordY@, CoordX@), 10
+ CoordY@ = CoordY@ + D@
+ WEND
+ ENDIF
+ELSE
+ REM More horizontal line
+ IF AbsDX@ <= 1@ THEN
+ REM The same pixel or neighboring ones, because AbsDY@ < AbsDX@ <= 1.
+ PSET (Y@, X@), 10
+ PSET (YN@, XN@), 10
+ ELSE
+ REM There are pixels in between.
+ A@ = DY@ / DX@
+ IF XN@ >= X@ THEN
+ D@ = 1@
+ ELSE
+ D@ = -1@
+ ENDIF
+ CoordX@ = X@
+ WHILE CoordX@ <= XN@
+ CoordY@ = CoordX@ - X@
+ CoordY@ = A@ * CoordY@
+ CoordY@ = Y@ + CoordY@
+ PSET (CoordY@, CoordX@), 10
+ CoordX@ = CoordX@ + D@
+ WEND
+ ENDIF
+ENDIF
+RETURN
diff --git a/Task/Dragon-curve/Applesoft-BASIC/dragon-curve.basic b/Task/Dragon-curve/Applesoft-BASIC/dragon-curve.basic
new file mode 100644
index 0000000000..b9f8bff709
--- /dev/null
+++ b/Task/Dragon-curve/Applesoft-BASIC/dragon-curve.basic
@@ -0,0 +1,37 @@
+10 REM Dragon curve
+20 DEF FN MOD(M) = M - INT(M / 8) * 8
+30 REM SIN, COS in arrays for PI/4 multipl.
+40 DIM S(7), C(7)
+50 QPI = ATN(1): SQ = SQR(2)
+60 FOR I = 0 TO 7
+70 S(I) = SIN(I * QPI): C(I) = COS(I * QPI)
+80 NEXT I
+90 LEVEL = 15
+100 INSIZE = 128: REM 2^WHOLE_NUM (looks better)
+110 X = 98: Y = 68
+120 ROTQPI = 0: RQ = 1
+130 DIM R(LEVEL)
+140 HGR2: HCOLOR = 1
+150 GOSUB 170
+160 END
+170 REM ** Dragon
+180 ROTQPI = FN MOD8(ROTQPI)
+190 IF LEVEL > 1 THEN GOTO 250
+200 YN = S(ROTQPI) * INSIZE + Y
+210 XN = C(ROTQPI) * INSIZE + X
+220 HPLOT X, Y TO XN, YN
+230 X = XN: Y = YN
+240 RETURN
+250 INSIZE = INSIZE * SQ / 2
+260 ROTQPI = FN MOD8(ROTQPI + RQ)
+270 LEVEL = LEVEL - 1
+280 R(LEVEL) = RQ: RQ = 1
+290 GOSUB 170
+300 ROTQPI = FN MOD8(ROTQPI - R(LEVEL) * 2)
+310 RQ = -1
+320 GOSUB 170
+330 RQ = R(LEVEL)
+340 ROTQPI = FN MOD8(ROTQPI + RQ)
+350 LEVEL = LEVEL + 1
+360 INSIZE = INSIZE * SQ
+370 RETURN
diff --git a/Task/Dragon-curve/Nascom-BASIC/dragon-curve.basic b/Task/Dragon-curve/Nascom-BASIC/dragon-curve.basic
new file mode 100644
index 0000000000..2f42679f86
--- /dev/null
+++ b/Task/Dragon-curve/Nascom-BASIC/dragon-curve.basic
@@ -0,0 +1,54 @@
+10 REM Dragon curve
+20 REM SIN, COS in arrays for PI/4 multipl.
+30 DIM S(7), C(7)
+40 QPI=ATN(1):SQ=SQR(2)
+50 FOR I=0 TO 7
+60 S(I)=SIN(I*QPI):C(I)=COS(I*QPI)
+70 NEXT I
+80 LEVEL=15
+90 INSIZE=32:REM 2^WHOLE_NUM (looks better)
+100 X=34:Y=16
+110 ROTQPI=0:RQ=1
+120 DIM R(LEVEL)
+130 CLS
+140 GOSUB 160
+150 END
+160 REM ** Dragon
+170 ROTQPI=ROTQPI AND 7
+180 IF LEVEL>1 THEN GOTO 240
+190 YN=S(ROTQPI)*INSIZE+Y
+200 XN=C(ROTQPI)*INSIZE+X
+210 GOSUB 370
+220 X=XN:Y=YN
+230 RETURN
+240 INSIZE=INSIZE*SQ/2
+250 ROTQPI=(ROTQPI+RQ)AND 7
+260 LEVEL=LEVEL-1
+270 R(LEVEL)=RQ:RQ=1
+280 GOSUB 160
+290 ROTQPI=(ROTQPI-R(LEVEL)*2)AND 7
+300 RQ=-1
+310 GOSUB 160
+320 RQ=R(LEVEL)
+330 ROTQPI=(ROTQPI+RQ)AND 7
+340 LEVEL=LEVEL+1
+350 INSIZE=INSIZE*SQ
+360 RETURN
+370 REM ** Draw a line from (X, Y) to (XN, YN)
+380 IF ABS(XN-X)>1 OR ABS(YN-Y)>1 THEN 400
+390 SET(X,Y):SET(XN,YN):RETURN
+400 IF ABS(XN-X)>ABS(YN-Y) THEN 480
+410 REM More vertical line
+420 A=(XN-X)/(YN-Y)
+430 IF YN>Y THEN D=1 ELSE D=-1
+440 FOR YC=Y TO YN STEP D
+450 SET(X+A*(YC-Y),YC)
+460 NEXT YC
+470 RETURN
+480 REM More horizontal line
+490 A=(YN-Y)/(XN-X)
+500 IF XN>X THEN D=1 ELSE D=-1
+510 FOR XC=X TO XN STEP D
+520 SET(XC,Y+A*(XC-X))
+530 NEXT XC
+540 RETURN
diff --git a/Task/Draw-a-clock/Atari-BASIC/draw-a-clock.basic b/Task/Draw-a-clock/Atari-BASIC/draw-a-clock.basic
new file mode 100644
index 0000000000..ef54e7f437
--- /dev/null
+++ b/Task/Draw-a-clock/Atari-BASIC/draw-a-clock.basic
@@ -0,0 +1,45 @@
+10 GRAPHICS 7:DEG
+20 PRINT "Please enter current time (HH,MM):"
+30 INPUT HH,MM:GRAPHICS 7+16
+40 FPS=60:REM SYSTEM CAN BE EITHER NTSC OR PAL
+50 IF PEEK(53268)=1 THEN FPS=50
+60 MINUTE=60*FPS
+70 XC=80:YC=40:R=35:RF=38
+80 GOSUB 800
+90 SETCOLOR 0,3,10:SETCOLOR 4,8,2:SETCOLOR 2,13,14
+100 POKE 19,0:POKE 20,0:SS=0:REM RESET FOR NEXT MINUTE
+200 COLOR 0:IF SS>0 THEN 230
+210 PLOT XC,YC:DRAWTO HX,HY
+220 PLOT XC,YC:DRAWTO MX,MY
+230 PLOT XC,YC:DRAWTO SX,SY
+240 GOSUB 500
+250 COLOR 2
+260 PLOT XC,YC:DRAWTO HX,HY
+270 PLOT XC,YC:DRAWTO MX,MY
+280 COLOR 1
+290 PLOT XC,YC:DRAWTO SX,SY
+300 JIFFIES=256*PEEK(19)+PEEK(20)
+310 NSEC=INT(JIFFIES/FPS):IF NSEC=60 THEN GOSUB 400:GOTO 100
+320 IF NSEC>SS THEN SS=NSEC:GOTO 2OO
+330 GOTO 300
+400 REM INCREASE MINUTE AND HOUR
+410 MM=MM+1
+420 IF MM=60 THEN MM=0:HH=HH+1
+430 IF HH=24 THEN HH=0
+440 REM DISABLE SCREEN SAVER/ATTRACT MODE
+450 POKE 77,0
+460 RETURN
+500 IF SS>0 THEN 550:REM CALCULATE X AND Y POSITIONS OF HANDS
+510 HX=XC+R*SIN(30*HH+MM/2)*0.5
+520 HY=YC-R*COS(30*HH+MM/2)*0.5
+530 MX=XC+R*SIN(6*MM)
+540 MY=YC-R*COS(6*MM)
+550 SX=XC+R*SIN(6*SS)
+560 SY=YC-R*COS(6*SS)
+570 RETURN
+800 REM DRAW CLOCK FACE
+810 COLOR 3
+820 FOR I=30 TO 360 STEP 30
+830 PLOT XC+RF*SIN(I),YC-RF*COS(I)
+840 NEXT I
+850 RETURN
diff --git a/Task/Draw-a-clock/EasyLang/draw-a-clock.easy b/Task/Draw-a-clock/EasyLang/draw-a-clock.easy
index 7d2dc2ddee..6befc2a8d8 100644
--- a/Task/Draw-a-clock/EasyLang/draw-a-clock.easy
+++ b/Task/Draw-a-clock/EasyLang/draw-a-clock.easy
@@ -1,5 +1,4 @@
proc draw hour min sec . .
- # dial
color 333
move 50 50
circle 45
@@ -16,18 +15,15 @@ proc draw hour min sec . .
move 50 + sin a * 40 50 + cos a * 40
circle 1
.
- # hour
linewidth 2
color 000
a = (hour * 60 + min) / 2
move 50 50
line 50 + sin a * 32 50 + cos a * 32
- # min
linewidth 1.5
a = (sec + min * 60) / 10
move 50 50
line 50 + sin a * 40 50 + cos a * 40
- # sec
linewidth 1
color 700
a = sec * 6
@@ -41,11 +37,9 @@ on timer
sec = number substr h$ 18 2
min = number substr h$ 15 2
hour = number substr h$ 12 2
- if hour > 12
- hour -= 12
- .
+ if hour > 12 : hour -= 12
draw hour min sec
.
- timer 0.1
+ timer 0.05
.
timer 0
diff --git a/Task/Duffinian-numbers/Forth/duffinian-numbers.fth b/Task/Duffinian-numbers/Forth/duffinian-numbers.fth
new file mode 100644
index 0000000000..264737eeb8
--- /dev/null
+++ b/Task/Duffinian-numbers/Forth/duffinian-numbers.fth
@@ -0,0 +1,61 @@
+: gcd ( u1 u2 -- u3 )
+ dup 0= if drop exit then
+ tuck mod recurse ;
+
+: duffinian? ( u -- ? )
+ dup 2 = if drop false exit then
+ 1 >r dup 2
+ begin
+ over 2 mod 0=
+ while
+ dup r> + >r 2* swap 2/ swap
+ repeat
+ drop 3
+ begin
+ 2dup dup * >=
+ while
+ dup 1 >r
+ begin
+ 2 pick 2 pick mod 0=
+ while
+ dup r> + >r over * >r tuck / swap r>
+ repeat
+ 2r> * >r drop 2 +
+ repeat
+ drop
+ 2dup = if 2drop rdrop false exit then
+ dup 1 > if 1+ r> * else drop r> then
+ gcd 1 = ;
+
+: main
+ ." First 50 Duffinian numbers:" cr
+ 0 1
+ begin
+ over 50 <
+ while
+ dup duffinian? if
+ dup 3 .r
+ swap 1+ swap
+ over 10 mod 0= if cr else space then
+ then
+ 1+
+ repeat
+ 2drop
+ cr ." First 30 Duffinian triplets:" cr
+ 0 >r 0 1
+ begin
+ r@ 30 <
+ while
+ dup duffinian? if swap 1+ swap else nip 0 swap then
+ over 3 = if
+ r> 1+ >r
+ dup 2 - 5 .r space
+ dup 1- 5 .r space
+ dup 5 .r cr
+ then
+ 1+
+ repeat
+ rdrop 2drop ;
+
+main
+bye
diff --git a/Task/Duffinian-numbers/Lua/duffinian-numbers.lua b/Task/Duffinian-numbers/Lua/duffinian-numbers.lua
new file mode 100644
index 0000000000..a8422b4049
--- /dev/null
+++ b/Task/Duffinian-numbers/Lua/duffinian-numbers.lua
@@ -0,0 +1,58 @@
+function gcd(a, b)
+ while b ~= 0 do
+ a, b = b, a % b
+ end
+ return a
+end
+
+function duffinian(n)
+ if n == 2 then return false end
+ local total = 1
+ local power = 2
+ local m = n
+ while (n & 1) == 0 do
+ total = total + power
+ power = power << 1
+ n = n >> 1
+ end
+ local p = 3
+ while p * p <= n do
+ local sum = 1
+ local power = p
+ while n % p == 0 do
+ sum = sum + power
+ power = power * p
+ n = n / p
+ end
+ total = total * sum
+ p = p + 2
+ end
+ if m == n then return false end
+ if n > 1 then total = total * (n + 1) end
+ return gcd(total, m) == 1
+end
+
+print("First 50 Duffinian numbers:")
+count = 0
+n = 1
+while count < 50 do
+ if duffinian(n) then
+ count = count + 1
+ if count % 10 == 0 then space = 10 else space = 32 end
+ io.write(string.format('%3d%c', n, space))
+ end
+ n = n + 1
+end
+
+print("\nFirst 30 Duffinian triplets:")
+n = 1
+m = 0
+count = 0
+while count < 30 do
+ if duffinian(n) then m = m + 1 else m = 0 end
+ if m == 3 then
+ count = count + 1
+ print(string.format('%d, %d, %d', n - 2, n - 1, n))
+ end
+ n = n + 1
+end
diff --git a/Task/Duffinian-numbers/Refal/duffinian-numbers.refal b/Task/Duffinian-numbers/Refal/duffinian-numbers.refal
new file mode 100644
index 0000000000..576fa3f49d
--- /dev/null
+++ b/Task/Duffinian-numbers/Refal/duffinian-numbers.refal
@@ -0,0 +1,76 @@
+$ENTRY Go {
+ =
+ >>
+
+
+ >;
+};
+
+ShowTriple {
+ s.N = >;
+};
+
+Each {
+ s.F = ;
+ s.F t.I e.X = ;
+};
+
+Group {
+ s.N = ;
+ s.N e.X, : (e.1) e.2 = (e.1) ;
+};
+
+Gen {
+ s.N s.F = ;
+ 0 s.F s.I = ;
+ s.N s.F s.I, : {
+ True = s.I s.F >;
+ False = >;
+ };
+};
+
+DuffinianTriple {
+ s.N,
+ >
+ >: True True True = True;
+ s.N = False;
+};
+
+Duffinian {
+ s.N, : s.S,
+ : s.P,
+ s.S : {
+ s.P s.1 = False;
+ s.Q 1 = True;
+ s.1 s.2 = False;
+ };
+};
+
+Gcd {
+ s.A 0 = s.A;
+ s.A s.B = >;
+};
+
+SigmaSum {
+ s.N = 2 >;
+ s.N s.Sum s.D s.Max, : '+' = s.Sum;
+ s.N s.Sum s.D s.Max, : s.N = ;
+ s.N s.Sum s.D s.Max, : 0 =
+ >>
+ s.Max>;
+ s.N s.Sum s.D s.Max = s.Max>;
+};
+
+Sqrt {
+ 0 = 1;
+ 1 = 1;
+ s.N = >;
+ s.N s.X0,
+ > 2>: s.X1,
+ : {
+ '+' = ;
+ s.C = s.X0;
+ };
+};
diff --git a/Task/Duffinian-numbers/SETL/duffinian-numbers.setl b/Task/Duffinian-numbers/SETL/duffinian-numbers.setl
new file mode 100644
index 0000000000..792e5adddc
--- /dev/null
+++ b/Task/Duffinian-numbers/SETL/duffinian-numbers.setl
@@ -0,0 +1,48 @@
+program duffinian_numbers;
+ init sigma := divisor_sum_table(20000);
+
+ print("First 50 Duffinian numbers:");
+ loop for n in first(50, routine is_duffinian) do
+ nprint(lpad(str n, 6));
+ if (col +:= 1) mod 10 = 0 then print; end if;
+ end loop;
+
+ print;
+ print("First 15 Duffinian triplets:");
+ loop for n in first(15, routine is_duffinian_triplet) do
+ print(+/[lpad(str i, 6) : i in [n,n+1,n+2]]);
+ end loop;
+
+ proc first(num, pred);
+ ls := [];
+ loop while #ls < num do
+ loop until call(pred, n) do
+ n +:= 1;
+ end loop;
+ ls with:= n;
+ end loop;
+ return ls;
+ end proc;
+
+ proc is_duffinian_triplet(n);
+ return and/[is_duffinian(i) : i in [n,n+1,n+2]];
+ end proc;
+
+ proc is_duffinian(n);
+ return sigma(n) > n+1 and gcd(n, sigma(n)) = 1;
+ end proc;
+
+ proc gcd(a,b);
+ return if b=0 then a else gcd(b, a mod b) end;
+ end proc;
+
+ proc divisor_sum_table(sz);
+ ds := [0] * sz;
+ loop for i in [1..sz] do
+ loop for j in [i,i+i..sz] do
+ ds(j) +:= i;
+ end loop;
+ end loop;
+ return ds;
+ end proc;
+end program;
diff --git a/Task/Dutch-national-flag-problem/FutureBasic/dutch-national-flag-problem.basic b/Task/Dutch-national-flag-problem/FutureBasic/dutch-national-flag-problem.basic
index 59c514fbfe..f7c621a282 100644
--- a/Task/Dutch-national-flag-problem/FutureBasic/dutch-national-flag-problem.basic
+++ b/Task/Dutch-national-flag-problem/FutureBasic/dutch-national-flag-problem.basic
@@ -1,39 +1,39 @@
void local fn DrawBalls( y as long, balls as CFArrayRef, sort as BOOL )
-long col, prevCol = 0, x = 10
-CFArrayRef cols = @[fn ColorWithSRGB(.78,.06,.18,1.0),fn ColorWhite,fn ColorWithSRGB(0,.24,.65,1.0)]
-if ( sort ) then balls = fn ArraySortedArrayUsingSelector( balls, @"compare:" )
+ long col, prevCol = 0, x = 10
+ CFArrayRef cols = @[fn ColorWithSRGB(.78,.06,.18,1.0),fn ColorWhite,fn ColorWithSRGB(0,.24,.65,1.0)]
+ if ( sort ) then balls = fn ArraySortedArrayUsingSelector( balls, @"compare:" )
-pen -1
-for long i = 0 to len(balls) - 1
-col = intval(balls[i])
-if ( sort == YES )
-if ( col != prevCol ) then y += 30 : x = 10
-else
-if ( i > 0 && i % 15 == 0 ) then y += 30 : x = 10
-end if
-oval fill (x,y,30,30), cols[col]
-x += 30
-prevCol = col
-next
+ pen -1
+ for long i = 0 to len(balls) - 1
+ col = intval(balls[i])
+ if ( sort == YES )
+ if ( col != prevCol ) then y += 30 : x = 10
+ else
+ if ( i > 0 && i % 15 == 0 ) then y += 30 : x = 10
+ end if
+ oval fill (x,y,30,30), cols[col]
+ x += 30
+ prevCol = col
+ next
end fn
void local fn DutchNationalFlagProblem
-window 1, @"Dutch national flag problem", (0,0,470,230)
-WindowSetBackgroundColor( 1, fn ColorWithSRGB(1.0,.61,0,1.0) )
+ window 1, @"Dutch national flag problem", (0,0,470,230)
+ WindowSetBackgroundColor( 1, fn ColorWithSRGB(1.0,.61,0,1.0) )
-CFMutableArrayRef balls = fn MutableArrayNew
+ CFMutableArrayRef balls = fn MutableArrayNew
-text @"Menlo-Bold",, fn ColorWhite
+ text @"Menlo-Bold",, fn ColorWhite
-for long i = 0 to 29
-balls[i] = @(rnd(3)-1)
-next
+ for long i = 0 to 29
+ balls[i] = @(rnd(3)-1)
+ next
-print @"Unsorted:"
-fn DrawBalls( 20, balls, NO )
+ print @"Unsorted:"
+ fn DrawBalls( 20, balls, NO )
-print %(3,100)@"Sorted:"
-fn DrawBalls( 120, balls, YES )
+ print %(3,100)@"Sorted:"
+ fn DrawBalls( 120, balls, YES )
end fn
random
diff --git a/Task/Dutch-national-flag-problem/M2000-Interpreter/dutch-national-flag-problem-1.m2000 b/Task/Dutch-national-flag-problem/M2000-Interpreter/dutch-national-flag-problem-1.m2000
new file mode 100644
index 0000000000..12e0137b20
--- /dev/null
+++ b/Task/Dutch-national-flag-problem/M2000-Interpreter/dutch-national-flag-problem-1.m2000
@@ -0,0 +1,23 @@
+ SortElse=lambda white (a(), &swaps, &compares)->{
+ long mid=white
+ long i, j, k=len(a())-1
+ while j<=k
+
+ if a(j)mid then
+ compares+=2
+ swap a(j), a(k)
+ swaps++
+ k--
+ else
+ compares+=2
+ j++
+ end if
+ end while
+ =a()
+ }
diff --git a/Task/Dutch-national-flag-problem/M2000-Interpreter/dutch-national-flag-problem-2.m2000 b/Task/Dutch-national-flag-problem/M2000-Interpreter/dutch-national-flag-problem-2.m2000
new file mode 100644
index 0000000000..acaf408117
--- /dev/null
+++ b/Task/Dutch-national-flag-problem/M2000-Interpreter/dutch-national-flag-problem-2.m2000
@@ -0,0 +1,88 @@
+function Dutch_national_flag_problem {
+ enum bands {red=1, white, blue}
+ s=red
+ check_in_order=lambda s, (a as array) ->{
+ boolean true=@true, false
+ k=each(a)
+ m=s
+ Z=S
+ =true
+ while k
+ z=array(k)
+ if m=z else
+ if m=blue then
+ =false
+ break
+ else
+ m++
+ if m=z else =false : break
+ end if
+ end if
+ end while
+ }
+ SortElse=lambda (m(), &swaps, &compares)->{
+ long t=len(m())
+ dim c(1 to 3)=t
+ c=1
+ for i=0 to len(m())-1
+ rem ? "pos:";i;" ";
+ w=m(i)
+ if w0
+ if c(k)=t then k-- : continue
+ if m(j)c(k) then c(m(j))=c(k)
+ rem ? "swap:";m(j);" at pos "+j;" with ";m(c(k)); " at pos ";c(k)
+ swap m(j), m(c(k))
+ rem ? "just swapped array :", m()#str$()
+ rem ? "c()", c()#str$()
+ swaps++
+ j=c(k)
+ c(k)++
+ end if
+ k--
+ rem ? "k=";k, c(k)
+ end while
+ else.if w>c then
+ c=w
+ if i-c(c)>1 else c(c)=i
+ end if
+ next
+ =m()
+ }
+ random_band=lambda->random(1, 3)
+ n=random(10, 20)
+ if n<3 then exit ' need at least 3 colors for the flag - although n now didn't get value 3 we place it to remember it later
+ do
+ do
+ dim balls(n)< {
- if size<1 then size=1
- randomitem=lambda a->a#val(random(0,2))
- dim a(size)<{
- Document r$=eval$(array(s))
- if len(s)>1 then
- For i=1 to len(s)-1 {
- r$=", "+eval$(array(s,i))
- }
- end if
- =r$
-}
-TestSort$=lambda$ (s as array)-> {
- ="unsorted: "
- x=array(s)
- for i=1 to len(s)-1 {
- k=array(s,i)
- if x>k then break
- swap x, k
- }
- ="sorted: "
-}
-Positions=lambda mid=White (a as array) ->{
- m=len(a)
- dim Base 0, b(m)=-1
- low=-1
- high=m
- m--
- i=0
- medpos=stack
- link a to a()
- for i=m to 0 {
- if a(i)<=mid then exit
- high--
- b(high)=high
- }
- for i=0 to m {
- if a(i)>=mid then exit
- low++
- b(low)=low
- }
- if high-low>1 then
- for i=low+1 to high-1 {
- select case a(i)<=>Mid
- case -1
- low++ : b(low)=i
- case 1
- {
- high-- :b(high)=i
- if High0 then
- dim c()
- c()=array(medpos)
- stock c(0) keep len(c()), b(low+1)
- for i=low+1 to high-1
- if b(i)>low and b(i)i then swap b(b(i)), b(i)
- next i
- end if
- if low>0 then
- for i=0 to low
- if b(i)<=low and b(i)<>i then swap b(b(i)), b(i)
- next
- end if
- if High=High and b(i)<>i then swap b(b(i)), b(i)
- next
- end if
- =b()
-}
-InPlace=Lambda (&p(), &Final()) ->{
- def i=0, j=-1, k=-1, many=0
- for i=0 to len(p())-1
- if p(i)<>i then
- j=i
- z=final(j)
- do
- final(j)=final(p(j))
- k=j
- j=p(j)
- p(k)=k
- many++
- until j=i
- final(k)=z
- end if
- next
- =many
-}
-
-
-Dim final(), p(), second(), p1()
-Rem final()=(White,Red,Blue,White,Red, Red, Blue)
-Rem final()=(white, blue, red, blue, white)
-
-final()=fillarray(30)
-Print "Items: ";len(final())
-Report TestSort$(final())+Display$(final())
-\\ backup for final() for second example
-second()=final()
-p()=positions(final())
-\\ backup p() to p1() for second example
-p1()=p()
-
-
-Report Center, "InPlace"
-rem Print p() ' show array items
-many=InPlace(&p(), &final())
-rem print p() ' show array items
-Report TestSort$(final())+Display$(final())
-print "changes: "; many
-
-
-Report Center, "Using another array to make the changes"
-final()=second()
-\\ using a second array to place only the changes
-item=each(p1())
-many=0
-While item {
- if item^=array(item) else final(item^)=second(array(item)) : many++
-}
-Report TestSort$(final())+Display$(final())
-print "changes: "; many
-Module three_way_partition (A as array, mid as balls, &swaps) {
- Def i, j, k
- k=Len(A)
- Link A to A()
- While j < k
- if A(j) < mid Then
- Swap A(i), A(j)
- swaps++
- i++
- j++
- Else.if A(j) > mid Then
- k--
- Swap A(j), A(k)
- swaps++
- Else
- j++
- End if
- End While
-}
-Many=0
-Z=second()
-Print
-Report center, {Three Way Partition
-}
-Report TestSort$(Z)+Display$(Z)
-three_way_partition Z, White, &many
-Print
-Report TestSort$(Z)+Display$(Z)
-Print "changes: "; many
diff --git a/Task/Eban-numbers/FutureBasic/eban-numbers.basic b/Task/Eban-numbers/FutureBasic/eban-numbers.basic
new file mode 100644
index 0000000000..e1246b9d9b
--- /dev/null
+++ b/Task/Eban-numbers/FutureBasic/eban-numbers.basic
@@ -0,0 +1,50 @@
+void local fn Eban( start as NSUInteger, finish as NSUInteger, printable as BOOL )
+ NSUInteger i, b, r, m, t, count
+
+ if ( start = 2 )
+ printf @"eban numbers up to and including %lu", finish
+ else
+ printf @"eban numbers between %lu and %lu:", start, finish
+ end if
+
+ count = 0
+ for i = start to finish step 2
+ b = int(i / 100000000)
+ r = i % 100000000
+ m = int(r / 1000000)
+ r = i % 1000000
+ t = int(r / 1000)
+ r = r % 1000
+ if m >= 30 && m <= 66 then m = (m % 10)
+ if t >= 30 && t <= 66 then t = (t % 10)
+ if r >= 30 && r <= 66 then r = (r % 10)
+ if b = 0 || b = 2 || b = 4 || b = 6
+ if m = 0 || m = 2 || m = 4 || m = 6
+ if t = 0 || t = 2 || t = 4 || t = 6
+ if r = 0 || r = 2 || r = 4 || r = 6
+ if printable == YES then printf @"%lu \b", i
+ count++
+ end if
+ end if
+ end if
+ end if
+ next
+ if printable == YES then print
+ printf @"%lu eban numbers found\n", count
+end fn
+
+void local fn EbanNumbers
+ CFTimeInterval t = fn CACurrentMediaTime
+ fn Eban( 2, 1000, YES )
+ fn Eban( 1000, 4000, YES )
+ fn Eban( 2, 10000, NO )
+ fn Eban( 2, 100000, NO )
+ fn Eban( 2, 1000000, NO )
+ fn Eban( 2, 10000000, NO )
+ fn Eban( 2, 100000000, NO )
+ printf @"Compute time: %.3f sec\n", fn CACurrentMediaTime - t
+end fn
+
+fn EbanNumbers
+
+HandleEvents
diff --git a/Task/Eban-numbers/OxygenBasic/eban-numbers.basic b/Task/Eban-numbers/OxygenBasic/eban-numbers.basic
new file mode 100644
index 0000000000..ba5f4082c8
--- /dev/null
+++ b/Task/Eban-numbers/OxygenBasic/eban-numbers.basic
@@ -0,0 +1,54 @@
+uses console
+
+! GetTickCount lib "kernel32.dll"
+double t1, t2
+
+sub eban (start as int, ended as int, printable as int)
+ int contar
+ long i, b, r, m, t
+
+ contar = 0
+ if start = 2 then
+ printl "eban numbers up to and including " ended ":"
+ else
+ printl "eban numbers between " start " and " ended " (inclusive):"
+ end if
+
+ for i = start to ended step 2
+ b = (i \ 1000000000)
+ r = mod(i, 1000000000)
+ m = (r \ 1000000)
+ r = mod(i, 1000000)
+ t = (r \ 1000)
+ r = mod(r, 1000)
+ if m >= 30 and m <= 66 then m = mod(m, 10)
+ if t >= 30 and t <= 66 then t = mod(t, 10)
+ if r >= 30 and r <= 66 then r = mod(r, 10)
+ if b = 0 or b = 2 or b = 4 or b = 6 then
+ if m = 0 or m = 2 or m = 4 or m = 6 then
+ if t = 0 or t = 2 or t = 4 or t = 6 then
+ if r = 0 or r = 2 or r = 4 or r = 6 then
+ if printable then print i " ";
+ contar += 1
+ end if
+ end if
+ end if
+ end if
+ next i
+ if printable then print cr
+ printl "count = " contar cr
+end sub
+
+t1 = GetTickCount
+call eban (2, 1000, 1)
+call eban (1000, 4000, 1)
+call eban (2, 10000, 0)
+call eban (2, 100000, 0)
+call eban (2, 1000000, 0)
+call eban (2, 10000000, 0)
+call eban (2, 100000000, 0)
+t2 = GetTickCount
+printl "Run time: " (t2-t1)/1000 " seconds."
+
+printl cr "Enter ..."
+waitkey
diff --git a/Task/Echo-server/FutureBasic/echo-server.basic b/Task/Echo-server/FutureBasic/echo-server.basic
new file mode 100644
index 0000000000..f0a415f3d2
--- /dev/null
+++ b/Task/Echo-server/FutureBasic/echo-server.basic
@@ -0,0 +1,16 @@
+// Echo Server
+// https://rosettacode.org/wiki/Echo_server#
+
+#plist NSAppleEventsUsageDescription @"Access to Apple Events is needed for this task."
+
+str255 theMessage
+theMessage = "tell application " + CHR$(34) + "Terminal" + CHR$(34) + CHR$(10) + "activate" + CHR$(10)¬
++ "do script " + CHR$(34) + "ssh ::1" + CHR$(34) + CHR$(10) + "end tell" + CHR$(10)
+
+AppleScriptRef script
+script = fn AppleScriptWithSource( fn stringwithpascalstring (theMessage) )
+fn AppleScriptExecute( script, null )
+
+// Sends ssh ::1 as a terminal command to open a connection to the local host
+// You need to enable Sharing - Remote Login in System Settings for a succesful login.
+// Otherwise you will get a Connection Refused message from the terminal.
diff --git a/Task/Egyptian-division/FutureBasic/egyptian-division.basic b/Task/Egyptian-division/FutureBasic/egyptian-division.basic
new file mode 100644
index 0000000000..44246587ac
--- /dev/null
+++ b/Task/Egyptian-division/FutureBasic/egyptian-division.basic
@@ -0,0 +1,32 @@
+void local fn EgyptianDivision
+ int table(32, 2)
+ int i = 1, dividend = 580, divisor = 34
+ int answer, accumulator
+
+ table(i, 1) = 1
+ table(i, 2) = divisor
+
+ while ( table( i, 2 ) < dividend )
+ i++
+ table(i, 1) = table(i - 1, 1) * 2
+ table(i, 2) = table(i - 1, 2) * 2
+ wend
+ i--
+ answer = table(i, 1)
+ accumulator = table(i, 2)
+
+ while ( i > 1 )
+ i--
+ if table(i, 2) + accumulator <= dividend
+ answer += table(i, 1)
+ accumulator += table(i, 2)
+ end if
+ wend
+
+ printf @"Using Egyptian Division %d / %d = %d remainder %d", dividend, divisor, answer, dividend - accumulator
+end fn
+
+
+fn EgyptianDivision
+
+HandleEvents
diff --git a/Task/Egyptian-division/M2000-Interpreter/egyptian-division.m2000 b/Task/Egyptian-division/M2000-Interpreter/egyptian-division.m2000
new file mode 100644
index 0000000000..608f59ab55
--- /dev/null
+++ b/Task/Egyptian-division/M2000-Interpreter/egyptian-division.m2000
@@ -0,0 +1,32 @@
+MODULE LIKEBASIC {
+ 100 REM Egyptian division
+ 110 DIM Table(0 TO 31, 0 TO 1)
+ 120 LET Dividend = 580
+ 130 LET Divisor = 34
+ 140 REM ** Division
+ 150 LET I = 0
+ 160 LET Table(I, 0) = 1
+ 170 LET Table(I, 1) = Divisor
+ 180 WHILE Table(I, 1) < Dividend
+ 190 LET I = I + 1
+ 200 LET Table(I, 0) = Table(I - 1, 0) * 2
+ 210 LET Table(I, 1) = Table(I - 1, 1) * 2
+ 220 END WHILE
+ 230 LET I = I - 1
+ 240 LET Answer = Table(I, 0)
+ 250 LET Accumulator = Table(I, 1)
+ 260 WHILE I > 0
+ 270 LET I = I - 1
+ 280 IF Table(I, 1) + Accumulator <= Dividend THEN
+ 290 LET Answer = Answer + Table(I, 0)
+ 300 LET Accumulator = Accumulator + Table(I, 1)
+ 310 END IF
+ 320 END WHILE
+ 330 REM ** Results
+ 340 PRINT Dividend; " divided by "; Divisor; " using Egytian division";
+ 350 PRINT " returns "; Answer; " remainder "; Dividend - Accumulator
+ 360 END
+}
+' Change DO WHILE ...LOOP -> WHILE ...END WHILE
+' Adding some space for string literals
+LIKEBASIC
diff --git a/Task/Elementary-cellular-automaton-Random-number-generator/ALGOL-68/elementary-cellular-automaton-random-number-generator.alg b/Task/Elementary-cellular-automaton-Random-number-generator/ALGOL-68/elementary-cellular-automaton-random-number-generator.alg
new file mode 100644
index 0000000000..a495116d55
--- /dev/null
+++ b/Task/Elementary-cellular-automaton-Random-number-generator/ALGOL-68/elementary-cellular-automaton-random-number-generator.alg
@@ -0,0 +1,48 @@
+BEGIN # elementary cellular automaton - random number generation #
+ COMMENT returns the next state from state using rule s must be at least 2 characters long
+ and consist of # and - only
+ COMMENT
+ PROC next state = ( STRING state, INT rule )STRING:
+ BEGIN
+ COMMENT returns 1 or 0 depending on whether c = # or not COMMENT
+ OP TOINT = ( CHAR c )INT: IF c = "#" THEN 1 ELSE 0 FI;
+ # construct the state with additional extra elements to allow wrap-around #
+ STRING s = state[ UPB state ] + state + state[ LWB state : LWB state + 1 ];
+ COMMENT convert rule to a string of # or - depending on whether the bits of r are on or off
+ COMMENT
+ STRING r := "";
+ INT v := rule;
+ TO 8 DO
+ r +:= IF ODD v THEN "#" ELSE "-" FI;
+ v OVERAB 2
+ OD;
+ STRING new state := "";
+ FOR i FROM LWB s TO UPB s - 3 DO
+ CHAR c1 = s[ i ];
+ CHAR c2 = s[ i + 1 ];
+ CHAR c3 = s[ i + 2 ];
+ INT pos := ( ( ( TOINT c1 * 2 ) + TOINT c2 ) * 2 ) + TOINT c3;
+ new state +:= r[ pos + 1 ]
+ OD;
+ new state
+ END # next state # ;
+ # get a pseudo-random byte from by evolving the state #
+ PROC get byte = ( REF STRING state, INT rule, element )INT:
+ BEGIN
+ BITS b := 16r0;
+ TO 8 DO
+ state := next state( state, rule );
+ b := b SHL 1;
+ IF state[ element ] = "#" THEN b := b OR 16r1 FI
+ OD;
+ ABS b
+ END # get byte # ;
+
+ BEGIN # test #
+ STRING rg state := "###############################################################-";
+ TO 10 DO
+ print( ( " ", whole( get byte( rg state, 30, 1 ), 0 ) ) )
+ OD;
+ print( ( newline ) )
+ END
+END
diff --git a/Task/Empty-string/EMal/empty-string.emal b/Task/Empty-string/EMal/empty-string.emal
index 4dd34da9b1..d6165ca73b 100644
--- a/Task/Empty-string/EMal/empty-string.emal
+++ b/Task/Empty-string/EMal/empty-string.emal
@@ -1,9 +1,9 @@
# Demonstrate how to assign an empty string to a variable.
-text sampleA = Text.EMPTY
-text sampleB = "hello world"
-text sampleC = ""
-List samples = text[sampleA, sampleB, sampleC]
+text sampleA ← Text.EMPTY
+text sampleB ← "hello world"
+text sampleC ← ""
+List samples ← text[sampleA, sampleB, sampleC]
for each text sample in samples
# Demonstrate how to check that a string is empty.
- writeLine("Is '" + sample + "' empty? " + when(sample.isEmpty(), "Yes", "No") + ".")
+ writeLine("Is '", sample, "' empty? ", when(sample.isEmpty(), "Yes", "No"), ".")
end
diff --git a/Task/Entropy/FutureBasic/entropy.basic b/Task/Entropy/FutureBasic/entropy.basic
new file mode 100644
index 0000000000..9ef9433d59
--- /dev/null
+++ b/Task/Entropy/FutureBasic/entropy.basic
@@ -0,0 +1,34 @@
+include "NSLog.incl"
+
+double local fn Entropy( array as CFArrayRef )
+ CFMutableDictionaryRef count = fn MutableDictionaryNew
+
+ for CFStringRef element in array
+ if ( count[element] )
+ count[element] = @(fn NumberIntegerValue( count[element] ) + 1)
+ else
+ count[element] = @(1)
+ end if
+ next
+
+ double entropy = 0.0
+ NSUInteger total = fn ArrayCount( array )
+ CFArrayRef valuesArr = fn DictionaryAllValues( count )
+
+ for CFNumberRef value in valuesArr
+ double p = fn NumberDoubleValue( value ) / total
+ entropy -= p * log(p)
+ next
+ return entropy / log(2)
+end fn = 0.0
+
+void local fn DoIt
+ CFStringRef string = @"1,2,2,3,3,3,4,4,4,4"
+ CFArrayRef characters = fn StringComponentsSeparatedByString( string, @"," )
+ double result = fn Entropy( characters )
+ NSLog( @"Entrophy of \"%@\": %.15f", fn StringByReplacingOccurrencesOfString( string, @",", @"" ), result )
+end fn
+
+fn DoIt
+
+HandleEvents
diff --git a/Task/Enumerations/Crystal/enumerations.cr b/Task/Enumerations/Crystal/enumerations.cr
new file mode 100644
index 0000000000..7774d59b5e
--- /dev/null
+++ b/Task/Enumerations/Crystal/enumerations.cr
@@ -0,0 +1,78 @@
+# An enum is a set of integer values, where each value has an associated name.
+# For example:
+
+enum Color
+ Red # 0
+ Green # 1
+ Blue # 2
+end
+
+# Values start with the value 0 and are incremented by one,
+# but can be overwritten.
+
+# To get the underlying value you invoke value on it:
+
+Color::Green.value # => 1
+
+# Each constant (member) in the enum has the type of the enum:
+
+typeof(Color::Red) # => Color
+
+# An enum can be marked with the @[Flags] annotation.
+# This changes the default values:
+
+@[Flags]
+enum IOMode
+ Read # 1
+ Write # 2
+ Async # 4
+end
+
+# Additionally, some methods change their behaviour.
+
+# An enum can be created from an integer:
+
+Color.new(1).to_s # => "Green"
+
+# Values that don't correspond to enum's constants are allowed:
+# the value will still be of type Color, but when printed you will get
+# the underlying value:
+
+Color.new(10).to_s # => "10"
+
+# This method is mainly intended to convert integers from C to enums in Crystal.
+
+# An enum automatically defines question methods for each member,
+# using String#underscore for the method name.
+# * In the case of regular enums, this compares by equality (#==).
+# * In the case of flags enums, this invokes #includes?.
+# For example:
+
+color = Color::Blue
+color.red? # => false
+color.blue? # => true
+
+mode = IOMode::Read | IOMode::Async
+mode.read? # => true
+mode.write? # => false
+mode.async? # => true
+
+# This is very convenient in case expressions:
+
+case color
+when .red?
+ puts "Got red"
+when .blue?
+ puts "Got blue"
+end
+
+# The type of the underlying enum value is Int32 by default,
+# but it can be changed to any type in Int::Primitive.
+
+enum Color : UInt8
+ Red
+ Green
+ Blue
+end
+
+Color::Red.value # : UInt8
diff --git a/Task/Enumerations/EMal/enumerations.emal b/Task/Enumerations/EMal/enumerations.emal
index 60c6220bd6..5ceb8bdebe 100644
--- a/Task/Enumerations/EMal/enumerations.emal
+++ b/Task/Enumerations/EMal/enumerations.emal
@@ -5,13 +5,13 @@ enum
end
type ExplicitFruits
enum
- int APPLE = 10
- int BANANA = 20
- int CHERRY = 1
+ int APPLE ← 10
+ int BANANA ← 20
+ int CHERRY ← 1
end
type Main
for each generic enumeration in generic[Fruits, ExplicitFruits]
- writeLine("[" + Generic.name(enumeration) + "]")
+ writeLine("[", Generic.name(enumeration), "]")
writeLine("getting an object with value = 1:")
writeLine(:enumeration.byValue(1))
writeLine("iterating over the items:")
diff --git a/Task/Enumerations/M2000-Interpreter/enumerations.m2000 b/Task/Enumerations/M2000-Interpreter/enumerations.m2000
index 7d9cc5e6e1..3d20ecd98d 100644
--- a/Task/Enumerations/M2000-Interpreter/enumerations.m2000
+++ b/Task/Enumerations/M2000-Interpreter/enumerations.m2000
@@ -1,7 +1,29 @@
Module Checkit {
- \\ need revision 15, version 9.4
- Enum Fruit {apple, banana, cherry}
- Enum Fruit2 {apple2=10, banana2=20, cherry2=30}
+ Enum Fruit {
+ apple, banana, cherry
+ }
+ Enum Fruit2 {
+ apple2=10,
+ banana2=20.5,
+ cherry2=30
+ }
+ Enum StrType {
+ alfa="Άλφα",
+ beta="Βήτα",
+ gamma="Γάμμα",
+ delta="Δέλτα"
+ }
+ Print alfa, beta
+ z=alfa
+ z++
+ Print z=beta, eval$(z)="beta", z="Βήτα"
+ z="Γάμμα" ' change to 3rd by searching value from the list
+ CheckByReference2(&z)
+ z1=Each(StrType, -1, 1) ' from last to first
+ while z1
+ CheckByValue2(z1)
+ end while
+
Print apple, banana, cherry
Print apple2, banana2, cherry2
Print Len(apple)=0
@@ -47,10 +69,16 @@ Module Checkit {
Sub CheckByValue(z as Fruit2)
Print Eval$(z), z
End Sub
-
+ Sub CheckByValue2(z as StrType)
+ Print Eval$(z), z
+ End Sub
Sub CheckByReference(&z as Fruit2)
z++
Print Eval$(z), z
End Sub
+ Sub CheckByReference2(&z as StrType)
+ z++
+ Print Eval$(z), z
+ End Sub
}
Checkit
diff --git a/Task/Environment-variables/EMal/environment-variables.emal b/Task/Environment-variables/EMal/environment-variables.emal
index 1052e86a8f..c7cd2af565 100644
--- a/Task/Environment-variables/EMal/environment-variables.emal
+++ b/Task/Environment-variables/EMal/environment-variables.emal
@@ -1,6 +1,6 @@
-fun showVariable = n:
+ break
+ while n % p == 0:
+ factors.append(p)
+ n = n // p
+ if n > 1 and n in primes_set:
+ factors.append(n)
+ return factors
+
+
+def compute_categories(primes):
+ primes_set = set(primes)
+ category = {p: 0 for p in primes}
+ for p in primes:
+ m = p + 1
+ factors = factor(m, primes, primes_set)
+ if all(f in {2, 3} for f in factors):
+ category[p] = 1
+ else:
+ max_cat = 0
+ for q in factors:
+ q_cat = category.get(q, 0)
+ if q_cat > max_cat:
+ max_cat = q_cat
+ category[p] = max_cat + 1
+ return category
+
+
+def print_first_200(primes, category):
+ print("First 200 primes sorted by category:")
+ print("-" * 34)
+
+ # Create list of (category, prime, original_position)
+ sorted_primes = sorted(
+ [(category[p], p, i + 1) for i, p in enumerate(primes[:200])],
+ key=lambda x: (x[0], x[1])
+ )
+ # Group by category for better visualization
+ current_category = None
+ for cat, p, orig_pos in sorted_primes:
+ if cat != current_category:
+ print(f"\nCategory {cat}:")
+ current_category = cat
+ print(f"{p}", end=" ")
+
+
+def process_million_primes():
+ n = 10 ** 6
+ primes = generate_primes_sieve(n)
+ primes = primes[:n]
+ category = compute_categories(primes)
+
+ stats = defaultdict(lambda: {'count': 0, 'min': None, 'max': None})
+ for p in primes:
+ cat = category[p]
+ stats[cat]['count'] += 1
+ if stats[cat]['min'] is None or p < stats[cat]['min']:
+ stats[cat]['min'] = p
+ if stats[cat]['max'] is None or p > stats[cat]['max']:
+ stats[cat]['max'] = p
+
+ print("\n\nCategory statistics for first 1,000,000 primes:")
+ print(f"{'Category':<8} {'Count':>12} {'Smallest':>12} {'Largest':>12}")
+ print("-" * 48)
+ for cat in sorted(stats.keys()):
+ s = stats[cat]
+ print(f"{cat:<8} {s['count']:>12,} {s['min']:>12,} {s['max']:>12,}")
+
+
+# First part: Display first 200 primes sorted by category
+primes_200 = generate_primes_sieve(200)
+primes_200 = primes_200[:200]
+category_200 = compute_categories(primes_200)
+print_first_200(primes_200, category_200)
+
+# Second part: Process first million primes and display statistics
+process_million_primes()
diff --git a/Task/Ethiopian-multiplication/EMal/ethiopian-multiplication.emal b/Task/Ethiopian-multiplication/EMal/ethiopian-multiplication.emal
index 4f8456efb4..1247805063 100644
--- a/Task/Ethiopian-multiplication/EMal/ethiopian-multiplication.emal
+++ b/Task/Ethiopian-multiplication/EMal/ethiopian-multiplication.emal
@@ -1,13 +1,14 @@
-fun halve = int by int value do return value / 2 end
-fun double = int by int value do return value * 2 end
-fun isEven = logic by int value do return value % 2 == 0 end
-fun ethiopian = int by int multiplicand, int multiplier
+fun halve ← = 1
- if not isEven(multiplicand) do product += multiplier end
- multiplicand = halve(multiplicand)
- multiplier = double(multiplier)
+ while multiplicand ≥ 1
+ if not isEven(multiplicand) do product +← multiplier end
+ multiplicand ← halve(multiplicand)
+ multiplier ← double(multiplier)
end
return product
end
-writeLine(ethiopian(17, 34))
+writeLine(17, " x ", 34, " = ", ethiopian(17, 34))
+writeLine(99, " x ", 99, " = ", ethiopian(99, 99))
diff --git a/Task/Ethiopian-multiplication/M2000-Interpreter/ethiopian-multiplication.m2000 b/Task/Ethiopian-multiplication/M2000-Interpreter/ethiopian-multiplication.m2000
index 7b36107578..23beab8bf1 100644
--- a/Task/Ethiopian-multiplication/M2000-Interpreter/ethiopian-multiplication.m2000
+++ b/Task/Ethiopian-multiplication/M2000-Interpreter/ethiopian-multiplication.m2000
@@ -1,33 +1,23 @@
-Module EthiopianMultiplication{
- Form 60, 25
- Const Center=2, ColumnWith=12
- Report Center,"Ethiopian Method of Multiplication"
- // using decimals as unsigned integers
- Def Decimal leftval, rightval, sum
- (leftval, rightval)=(random(1, 65535), random(1, 65536))
- Print $( , ColumnWith), "Target:", leftval*rightval,
- Hex leftval*rightval
- sum=0
- if @IsEven(leftval) Else sum+=rightval
- Print leftval, rightval,
- Hex leftval, rightval
- while leftval>1
- leftval=@halveInt(leftval)
- rightval=@DoubleInt(rightval)
- Print leftval, rightval,
- Hex leftval, rightval
- if @IsEven(leftval) Else sum+=rightval
- End while
- Print "", sum
- Hex "", sum
- Function HalveInt(i)
- =Binary.Shift(i,-1)
- End Function
- Function DoubleInt(i)
- =Binary.Shift(i,1)
- End Function
- Function IsEven(i)
- =Binary.And(i, 1)=0
- End Function
+Function ethiopian(mr as long long, md as long long) {
+ def even()=number mod 2&&
+ def div2()=number div 2&&
+ def mul2()=number * 2&&
+ result=0&&
+ while mr>=1
+ if even(mr) then result+=md
+ mr=div2(mr)
+ md=mul2(md)
+ end while
+ =result
}
-EthiopianMultiplication
+Print ethiopian(17, 34)=578
+Function ethiopian(mr as long long, md as long long) {
+ result=0&&
+ while mr>=1
+ if mr mod 2 then result+=md
+ mr|div 2&
+ md*=2&
+ end while
+ =result
+}
+Print ethiopian(17, 34)=578
diff --git a/Task/Eulers-identity/M2000-Interpreter/eulers-identity.m2000 b/Task/Eulers-identity/M2000-Interpreter/eulers-identity.m2000
new file mode 100644
index 0000000000..ba35d26c68
--- /dev/null
+++ b/Task/Eulers-identity/M2000-Interpreter/eulers-identity.m2000
@@ -0,0 +1,105 @@
+Class Complex {
+private:
+ double vr, vi
+ final pidivby180=pi/180
+ final e=2.71828182845905
+public:
+ property real {
+ value {link parent vr to vr : value=vr}
+ }
+ property imaginary {
+ value {link parent vi to vi : value=vi}
+ }
+ property toString {
+ value { clear 'so a new clear as string created after
+ link parent vr, vi to vr, vi
+ if vi then
+ if vr then
+ if vi>0 then
+ value="("+vr+"+"+vi+"i)"
+ else
+ value="("+vr+""+vi+"i)"
+ end if
+ else
+ value="("+vi+"i)"
+ end if
+ else
+ value="("+vr+")"
+ end if
+ }
+ }
+ function exp {
+ double exp = .e^.vr
+ c=this
+ c.vr<=exp * cos(.vi/.pidivby180)
+ c.vi<=exp * sin(.vi/.pidivby180)
+ =c
+ }
+ function conj {
+ c=this : c.vi-! : =c
+ }
+ function absc {
+ c=this*.conj() : =sqrt(c.vr)
+ }
+ operator "+" {
+ read k as Complex : .vr+= k.vr : .vi+= k.vi
+ }
+ operator "-" {
+ read k as Complex : .vr-= k.vr : .vi-= k.vi
+ }
+ operator "*" {
+ read k as Complex
+ double ivr = .vr*k.vr-.vi*k.vi
+ .vi <= .vi*k.vr+.vr*k.vi
+ .vr <= ivr
+ }
+ operator "/" {
+ read k as Complex
+ k1=k*k.conj()
+ acb = this*k.conj()
+ .vr <= acb.vr/k1.vr
+ .vi <= acb.vi/k1.vr
+ }
+class:
+ module Complex (.vr, .vi) {}
+}
+module Check (filename$="") {
+ const MAXITER=12&
+ long i, k = 2
+ pii=Complex(0, pi)
+ pii2 = pii*pii
+ B0 = Complex(2)
+ A0 = Complex(2)
+ B1 = Complex(2) - pii
+ A1 = B0*B1 + Complex(2)*pii
+ open filename$ for output as #f
+ printc(A0/B0)
+ print #f, " Absolute error = ";@absc(A0/B0)
+ printc(A1/B1)
+ print #f, " Absolute error = ";@absc(A1/B1)
+ for i = 1 to MAXITER
+ k += 4
+ A2 = Complex(k)*A1 + pii2*A0
+ B2 = Complex(k)*B1 + pii2*B0
+ try ok {curr = A2/B2}
+ if not ok then exit for
+ A0 = A1
+ A1 = A2
+ B0 = B1
+ B1 = B2
+ printc(curr)
+ print #f, " Absolute error = "; curr.absc()
+ next i
+ r=pii.exp()+Complex(1)
+ Print #f, "e^(πi)+1 = ";r.toString
+ close#f
+ if f<>-2 and exist(dir$+filename$) then win "notepad", dir$+filename$
+ end
+ sub printc(c as Complex)
+ Print #f, c.toString
+ end sub
+ function absc(c as complex)
+ =c.absc()
+ end function
+}
+Check ' use Check "out.txt"
diff --git a/Task/Evaluate-binomial-coefficients/PascalABC.NET/evaluate-binomial-coefficients.pas b/Task/Evaluate-binomial-coefficients/PascalABC.NET/evaluate-binomial-coefficients.pas
index 2abbe607cb..e211b2dd47 100644
--- a/Task/Evaluate-binomial-coefficients/PascalABC.NET/evaluate-binomial-coefficients.pas
+++ b/Task/Evaluate-binomial-coefficients/PascalABC.NET/evaluate-binomial-coefficients.pas
@@ -3,7 +3,7 @@ function binomial(n, k: integer): biginteger;
begin
result := 1bi;
for var i := 1 to k do
- result *= (n - i + 1) div i;
+ result = result * (n - i + 1) div i;
end;
Println(binomial(5, 3))
diff --git a/Task/Evaluate-binomial-coefficients/Quackery/evaluate-binomial-coefficients.quackery b/Task/Evaluate-binomial-coefficients/Quackery/evaluate-binomial-coefficients.quackery
index 84ddfed0ec..067fbe1414 100644
--- a/Task/Evaluate-binomial-coefficients/Quackery/evaluate-binomial-coefficients.quackery
+++ b/Task/Evaluate-binomial-coefficients/Quackery/evaluate-binomial-coefficients.quackery
@@ -2,6 +2,6 @@
1 swap times
[ over i + 1+ * ]
nip swap times
- [ i 1+ / ] ] is binomial ( n n --> )
+ [ i 1+ / ] ] is binomial ( n n --> n )
5 3 binomial echo
diff --git a/Task/Even-or-odd/ALGOL-60/even-or-odd.alg b/Task/Even-or-odd/ALGOL-60/even-or-odd.alg
new file mode 100644
index 0000000000..314105fd32
--- /dev/null
+++ b/Task/Even-or-odd/ALGOL-60/even-or-odd.alg
@@ -0,0 +1,21 @@
+begin
+
+integer i;
+
+boolean procedure even(n);
+ value n; integer n;
+begin
+ even := (n = entier(n/2) * 2);
+end;
+
+comment - exercise the function;
+for i := 1 step 3 until 12 do
+ begin
+ outinteger(1,i);
+ if even(i) then
+ outstring(1,"is even\n")
+ else
+ outstring(1,"is odd\n");
+ end;
+
+end
diff --git a/Task/Even-or-odd/EMal/even-or-odd.emal b/Task/Even-or-odd/EMal/even-or-odd.emal
index 0292abacd4..ee2b7e1cd8 100644
--- a/Task/Even-or-odd/EMal/even-or-odd.emal
+++ b/Task/Even-or-odd/EMal/even-or-odd.emal
@@ -1,20 +1,16 @@
-List evenCheckers = fun[
- logic by int i do return i % 2 == 0 end,
- logic by int i do return i & 1 == 0 end]
-List oddCheckers = fun[
- logic by int i do return i % 2 != 0 end,
- logic by int i do return i & 1 == 1 end]
-writeLine("integer".padStart(10, " ") + "|is_even" + "|is_odd |")
+List evenCheckers ← fun[
+ candidate_fitness
+ candidate, candidate_fitness = child, child_fitness
+ end
+ end
+ candidate
+end
+
+parent = TARGET.map { ALPHABET.sample }
+
+(1..).each do |gen|
+ printf "%4d %s\n", gen, parent.join
+ break if parent == TARGET
+ parent = next_parent(parent, TARGET, C, RATE)
+end
diff --git a/Task/Evolutionary-algorithm/FutureBasic/evolutionary-algorithm.basic b/Task/Evolutionary-algorithm/FutureBasic/evolutionary-algorithm.basic
new file mode 100644
index 0000000000..36c9824034
--- /dev/null
+++ b/Task/Evolutionary-algorithm/FutureBasic/evolutionary-algorithm.basic
@@ -0,0 +1,80 @@
+include "NSLog.incl"
+
+begin globals
+ CFStringRef target
+ CFStringRef alphabet
+ NSInteger c
+ CGFloat p
+end globals
+
+target = @"METHINKS IT IS LIKE A WEASEL"
+alphabet = @"ABCDEFGHIJKLMNOPQRSTUVWXYZ "
+c = 100
+p = 0.06
+
+toolbox fn arc4random_uniform( UInt32 upperbound ) = UInt32
+
+local fn Fitness( s as CFStringRef ) as NSInteger
+ NSInteger score = len(target)
+ for NSInteger i = 0 to len(target) -1
+ if ( ucc(s,i) == ucc(target,i) ) then score--
+ next
+end fn = score
+
+local fn Mutate( s as CFStringRef, rate as CGFloat ) as CFStringRef
+ CFMutableStringRef result = fn MutableStringWithString( @"" )
+ for NSInteger i = 0 to len(s) -1
+ if ( ( fn arc4random_uniform(100) / 100.0) < rate )
+ NSInteger idx = fn arc4random_uniform( (UInt32)len(alphabet) )
+ MutableStringAppendFormat( result, @"%C", ucc( alphabet, idx ) )
+ else
+ MutableStringAppendFormat( result, @"%C", ucc( s, i ) )
+ end if
+ next
+end fn = result
+
+local fn RandomString( length as NSInteger ) as CFStringRef
+ CFMutableStringRef result = fn MutableStringWithString( @"" )
+ for NSInteger i = 0 to length -1
+ NSInteger idx = fn arc4random_uniform( (UInt32)len(alphabet) )
+ MutableStringAppendFormat( result, @"%C", ucc( alphabet, idx ) )
+ next
+end fn = result
+
+void local fn PrintStep( stepNum as NSInteger, s as CFStringRef, fit as NSInteger, result as CFMutableStringRef )
+ MutableStringAppendFormat( result, @"%3ld: %@ Distance: %ld\n", (long)stepNum, s, (long)fit )
+end fn
+
+local fn EvolveString as CFStringRef
+ CFMutableStringRef result = fn MutableStringNew
+ CFStringRef parent = fn RandomString( len(target) )
+ fn PrintStep( 0, parent, fn Fitness(parent), result )
+
+ NSInteger stepNum = 0
+ while ( fn StringIsEqual( parent, target ) == NO )
+ NSInteger bestFitness = len(target) + 1
+ CFStringRef bestChild = @""
+ CFStringRef child
+ NSInteger fit
+
+ for NSInteger i = 0 to c -1
+ child = fn Mutate( parent, p )
+ fit = fn Fitness( child )
+ if ( fit < bestFitness )
+ bestFitness = fit
+ bestChild = child
+ end if
+ next
+ parent = bestChild
+ stepNum++
+ fn PrintStep( stepNum, parent, bestFitness, result )
+ wend
+end fn = result
+
+CFTimeInterval t : t = fn CACurrentMediaTime
+CFStringRef result : result = fn EvolveString
+NSLog( @"\nCompute time: %.3f ms\n",(fn CACurrentMediaTime-t)*1000 )
+NSLog( @"%@", result )
+NSLogScrollToTop
+
+HandleEvents
diff --git a/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Langur/exceptions-catch-an-exception-thrown-in-a-nested-call.langur b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Langur/exceptions-catch-an-exception-thrown-in-a-nested-call.langur
index e376e53714..13d7a22492 100644
--- a/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Langur/exceptions-catch-an-exception-thrown-in-a-nested-call.langur
+++ b/Task/Exceptions-Catch-an-exception-thrown-in-a-nested-call/Langur/exceptions-catch-an-exception-thrown-in-a-nested-call.langur
@@ -4,7 +4,7 @@ val U1 = {"msg": "U1"}
val baz = fn i: throw if(i==0: U0; U1)
val bar = fn i: baz(i)
-val foo = impure fn() {
+val foo = fn*() {
for i in [0, 1] {
bar(i)
catch {
diff --git a/Task/Execute-Computer-Zero/M2000-Interpreter/execute-computer-zero.m2000 b/Task/Execute-Computer-Zero/M2000-Interpreter/execute-computer-zero.m2000
new file mode 100644
index 0000000000..90e8e54763
--- /dev/null
+++ b/Task/Execute-Computer-Zero/M2000-Interpreter/execute-computer-zero.m2000
@@ -0,0 +1,155 @@
+module Execute_Computer_Zero{
+ global byte MEM[31]=0XFF, PC=0
+ module ZERO (program$, f=-2, showrun, skipreadcode){
+ Enum Commands {
+ NOP=0X0, LDA=0X20, STA=0X40, ADD=0X60, SUB=0X80, BRZ=0XA0, JMP=0XC0, STP=0XE0
+ }
+ if skipreadcode then goto cont1
+ PC<=0
+ dim code$()
+ var crlf=chr$(13)+chr$(10) ' CRLF
+ var prname$="Program #1"
+ program$=replace$(chr$(9)," ", program$)
+ program$=replace$(",",crlf, program$)
+ program$=ucase$(filter$(program$, "()."))
+ code$()=piece$(program$, crlf)
+ document source$
+ for I=0 to len(code$())-1
+ tok$=trim$(LeftPart$(trim$(code$(I))+" ", " "))
+ part$=trim$(RightPart$(trim$(code$(I))+" 0", " "))
+ val=val(part$) MOD 32
+ ch$=left$(tok$,1)
+ c=0
+ if ch$="#" then
+ prname$=mid$(trim$(code$(I)), 2)
+ continue
+ end if
+ tok$=filter$(tok$, "+-_x!@#$%^&*/|><")
+ if ch$>="0" and ch$<="9" then
+ val=int(val(tok$)) mod 256
+ source$ =" "+hex$(PC, 1)+" "+hex$(val,1)+crlf
+ else.if tok$="" then
+ continue
+ else.if valid(eval(tok$)) then
+ c=eval(tok$)
+ source$ =" "+hex$(PC, 1)+" "+tok$+" "+hex$(val,1)+crlf
+ end if
+ MEM[PC]<=c+VAL
+ PC++
+ next
+ Print #f, "Program Name:";prname$
+ Print #f, source$;
+ Print #f, "Program Length ";PC;"bytes"
+ PC<=0
+cont1:
+ byte A=0, ADDR=0
+ structure Accumulator {
+ { A as Byte, Overflow as Byte
+ }
+ R as Integer
+ }
+ Accumulator AC
+ CM=STP
+ if showrun then Print #f, "PC MEM COM ADDR AC"
+ do
+ if inkey$=" " then Print "Break": exit
+ A=MEM[PC]
+ ADDR=A MOD 32
+ CM=A-ADDR
+ if showrun then Print #f, Hex$(PC,1);" ";hex$(A,1);" ";EVAL$(CM);" ";hex$(ADDR, 1);" ";Hex$(AC|A, 1)
+ select case CM
+ case NOP
+ PC++ : PC|MOD 32
+ case LDA
+ AC|R=MEM[ADDR]:PC++ : PC|MOD 32
+ case STA
+ MEM[ADDR]<=AC|A : PC++ : PC|MOD 32
+ case ADD
+ AC|R=AC|R+MEM[ADDR]:PC++ : PC|MOD 32
+ case SUB
+ AC|R=uint(AC|R-MEM[ADDR]): PC++ : PC|MOD 32
+ case BRZ
+ {
+ if AC|A then
+ PC++ : PC|MOD 32
+ if showrun then Print #f, "NON ZERO - CONTINUE"
+ else
+ PC<=A MOD 32
+ if showrun then Print #f, "BRANCH TO ";PC
+ end if
+ }
+ case JMP
+ PC<=A MOD 32:if showrun then Print #f, "JUMP TO ";PC
+ case STP
+ exit
+ end select
+ always
+ if skipreadcode else
+ Print #f, "STOP AT ";hex$(PC,1)
+ Print #f, "RESULT:";AC|A;"|0x";hex$(AC|A, 1)
+ Print #f, "NEGATIVE:"; IF$(AC|A>126->"1","0")
+ Print #f, "OVERFLOW:"; IF$(AC|Overflow>0->"1","0")
+ Print #f
+ end if
+ }
+ Flush
+ Data {
+ #add 2
+ LDA 3, ADD 4, STP 0, 2, 2
+ }
+ Data {#fibonacci
+ LDA 14, STA 15, ADD 13, STA 14,
+ LDA 15, STA 13, LDA 16, SUB 17,
+ BRZ 11, STA 16, JMP 0, LDA 14,
+ STP 0, 1, 1, 0 , 8, 1
+ }
+ Data {#8*7
+ LDA 12, ADD 10, STA 12, LDA 11, SUB 13,
+ STA 11, BRZ 8, JMP 0, LDA 12, STP 0,
+ 8, 7, 0, 1
+ }
+ Data {#linkedList
+ LDA 13, ADD 15, STA 5, ADD 16, STA 7, NOP 0, STA 14, NOP 0
+ , BRZ 11, STA 15, JMP 0, LDA 14, STP 0, LDA 0, 0, 28
+ , 1, 0, 0, 0, 6, 0, 2, 26
+ , 5, 20, 3, 30, 1, 22, 4, 24
+ }
+ Data { #0-255
+ LDA 3, SUB 4, STP 0, 0, 255
+ }
+ Data {#0-1
+ LDA 3, SUB 4, STP 0, 0, 1
+ }
+ Data {#1+255
+ LDA 3, ADD 4, STP 0, 1, 255
+ }
+ filename="run01.txt"
+ open filename for wide output as #d
+ while not empty
+ Zero letter$, d, false, false
+ end while
+ Zero { #prisoner
+ NOP 0, NOP 0, STP 0, 0, LDA 3, SUB 29, BRZ 18, LDA 3
+ , STA 29, BRZ 14, LDA 1, ADD 31, STA 1, JMP 2, LDA 0, ADD 31
+ , STA 0, JMP 2, LDA 3, STA 29, LDA 1, ADD 30, ADD 3, STA 1
+ , LDA 0, ADD 30, ADD 3, STA 0, JMP 2, 0, 1, 3
+ }, d, false, false
+
+ Enum Action {cooperate=0UB, defect}
+ byte AcA
+ PM=defect
+ for i=1 to 5
+ Print #d, "Round ";i;" ";field$(eval$(PM), 10);
+ PC++
+ mem[PC]<=pm
+ IF PM=cooperate THEN PM++ ELSE PM--
+ PC++
+ Zero {}, d, false, true
+ Read AcA
+ Print #d, "Player:";mem[0], " Computer:";mem[1]
+ next
+ close #d
+ if filename<>"" then win dir$+filename
+
+}
+Execute_Computer_Zero
diff --git a/Task/Execute-Computer-Zero/Quackery/execute-computer-zero.quackery b/Task/Execute-Computer-Zero/Quackery/execute-computer-zero.quackery
new file mode 100644
index 0000000000..27224d387f
--- /dev/null
+++ b/Task/Execute-Computer-Zero/Quackery/execute-computer-zero.quackery
@@ -0,0 +1,175 @@
+ [ 0 ] is NOP ( --> n )
+ [ 1 ] is LDA ( --> n )
+ [ 2 ] is STA ( --> n )
+ [ 3 ] is ADD ( --> n )
+ [ 4 ] is SUB ( --> n )
+ [ 5 ] is BRZ ( --> n )
+ [ 6 ] is JMP ( --> n )
+ [ 7 ] is STP ( --> n )
+
+ [ 0 ] is DATA ( --> n )
+ [ 0 ] is -- ( --> n )
+
+ [ stack 0 ] is acc ( --> s )
+ [ stack 0 ] is ip ( --> s )
+ [ stack false ] is flag ( --> n )
+
+ [ 0 ip replace 0 32 of ] is computer/zero ( --> [ )
+
+ [ 255 & swap 5 << |
+ swap ip share poke
+ 1 ip tally ] is , ( [ --> [ )
+
+ [ drop ] is nop ( [ n --> [ )
+
+ [ dip dup peek acc replace ] is lda ( [ n --> [ )
+
+ [ acc share unrot poke ] is sta ( [ n --> [ )
+
+ [ dip dup peek
+ acc take + 255 & acc put ] is add ( [ n --> [ )
+
+ [ dip dup peek negate
+ acc take + 255 & acc put ] is sub ( [ n --> [ )
+
+ [ acc share iff drop done
+ ip replace ] is brz ( [ n --> [ )
+
+ [ ip replace ] is jmp ( [ n --> [ )
+
+ [ drop true flag replace ] is stp ( [ n --> [ )
+
+ [ false flag replace
+ 0 acc replace
+ 0 ip replace
+ [ dup ip share peek
+ 1 ip tally
+ dup 31 & swap 5 >>
+ [ table
+ nop lda sta add
+ sub brz jmp stp ] do
+ flag share until ]
+ drop
+ acc share
+ say "acc = " dup echo
+ dup 128 & iff
+ [ say " or "
+ 127 ~ | echo ]
+ else drop cr ] is execute ( [ --> )
+
+ cr say " 2+2: "
+ computer/zero
+ ( 00 ) LDA 03 ,
+ ( 01 ) ADD 04 ,
+ ( 02 ) STP -- ,
+ ( 03 ) DATA 2 ,
+ ( 04 ) DATA 2 ,
+ execute
+ cr say " 7*8: "
+ computer/zero
+ ( 00 ) LDA 12 ,
+ ( 01 ) ADD 10 ,
+ ( 02 ) STA 12 ,
+ ( 03 ) LDA 11 ,
+ ( 04 ) SUB 13 ,
+ ( 05 ) STA 11 ,
+ ( 06 ) BRZ 08 ,
+ ( 07 ) JMP 00 ,
+ ( 08 ) LDA 12 ,
+ ( 09 ) STP -- ,
+ ( 10 ) DATA 8 ,
+ ( 11 ) DATA 7 ,
+ ( 12 ) DATA 0 ,
+ ( 13 ) DATA 1 ,
+ execute
+ cr say " Fibonacci: "
+ computer/zero
+ ( 00 ) LDA 14 ,
+ ( 01 ) STA 15 ,
+ ( 02 ) ADD 13 ,
+ ( 03 ) STA 14 ,
+ ( 04 ) LDA 15 ,
+ ( 05 ) STA 13 ,
+ ( 06 ) LDA 16 ,
+ ( 07 ) SUB 17 ,
+ ( 08 ) BRZ 11 ,
+ ( 09 ) STA 16 ,
+ ( 10 ) JMP 00 ,
+ ( 11 ) LDA 14 ,
+ ( 12 ) STP -- ,
+ ( 13 ) DATA 1 ,
+ ( 14 ) DATA 1 ,
+ ( 15 ) DATA 0 ,
+ ( 16 ) DATA 8 ,
+ ( 17 ) DATA 1 ,
+ execute
+ cr say "linked list: "
+ computer/zero
+ ( 00 ) LDA 13 ,
+ ( 01 ) ADD 15 ,
+ ( 02 ) STA 05 ,
+ ( 03 ) ADD 16 ,
+ ( 04 ) STA 07 ,
+ ( 05 ) NOP -- ,
+ ( 06 ) STA 14 ,
+ ( 07 ) NOP -- ,
+ ( 08 ) BRZ 11 ,
+ ( 09 ) STA 15 ,
+ ( 10 ) JMP 00 ,
+ ( 11 ) LDA 14 ,
+ ( 12 ) STP -- ,
+ ( 13 ) LDA 00 ,
+ ( 14 ) DATA 0 ,
+ ( 15 ) DATA 28 ,
+ ( 16 ) DATA 1 ,
+ ( 17 ) DATA 0 ,
+ ( 18 ) DATA 0 ,
+ ( 19 ) DATA 0 ,
+ ( 20 ) DATA 6 ,
+ ( 21 ) DATA 0 ,
+ ( 22 ) DATA 2 ,
+ ( 23 ) DATA 26 ,
+ ( 24 ) DATA 5 ,
+ ( 25 ) DATA 20 ,
+ ( 26 ) DATA 3 ,
+ ( 27 ) DATA 30 ,
+ ( 28 ) DATA 1 ,
+ ( 29 ) DATA 22 ,
+ ( 30 ) DATA 4 ,
+ ( 31 ) DATA 24 ,
+ execute
+ cr say " prisoner: "
+ computer/zero
+ ( 00 ) NOP -- ,
+ ( 01 ) NOP -- ,
+ ( 02 ) STP -- ,
+ ( 03 ) NOP -- ,
+ ( 04 ) LDA 03 ,
+ ( 05 ) SUB 29 ,
+ ( 06 ) BRZ 18 ,
+ ( 07 ) LDA 03 ,
+ ( 08 ) STA 29 ,
+ ( 09 ) BRZ 14 ,
+ ( 10 ) LDA 01 ,
+ ( 11 ) ADD 31 ,
+ ( 12 ) STA 01 ,
+ ( 13 ) JMP 02 ,
+ ( 14 ) LDA 00 ,
+ ( 15 ) ADD 31 ,
+ ( 16 ) STA 00 ,
+ ( 17 ) JMP 02 ,
+ ( 18 ) LDA 03 ,
+ ( 19 ) STA 29 ,
+ ( 20 ) LDA 01 ,
+ ( 21 ) ADD 30 ,
+ ( 22 ) ADD 03 ,
+ ( 23 ) STA 01 ,
+ ( 24 ) LDA 00 ,
+ ( 25 ) ADD 30 ,
+ ( 26 ) ADD 03 ,
+ ( 27 ) STA 01 ,
+ ( 28 ) JMP 02 ,
+ ( 29 ) DATA 0 ,
+ ( 30 ) DATA 1 ,
+ ( 31 ) DATA 3 ,
+ execute
diff --git a/Task/Execute-a-system-command/Wren/execute-a-system-command-1.wren b/Task/Execute-a-system-command/Wren/execute-a-system-command-1.wren
deleted file mode 100644
index c638a0983e..0000000000
--- a/Task/Execute-a-system-command/Wren/execute-a-system-command-1.wren
+++ /dev/null
@@ -1,8 +0,0 @@
-/* Execute_a_system_command.wren */
-class Command {
- foreign static exec(name, param) // the code for this is provided by Go
-}
-
-Command.exec("ls", "-lt")
-System.print()
-Command.exec("dir", "")
diff --git a/Task/Execute-a-system-command/Wren/execute-a-system-command-2.wren b/Task/Execute-a-system-command/Wren/execute-a-system-command-2.wren
deleted file mode 100644
index 2e0ffb7e03..0000000000
--- a/Task/Execute-a-system-command/Wren/execute-a-system-command-2.wren
+++ /dev/null
@@ -1,39 +0,0 @@
-/* Execute_a_system_command.go*/
-package main
-
-import (
- wren "github.com/crazyinfin8/WrenGo"
- "log"
- "os"
- "os/exec"
-)
-
-type any = interface{}
-
-func execCommand(vm *wren.VM, parameters []any) (any, error) {
- name := parameters[1].(string)
- param := parameters[2].(string)
- var cmd *exec.Cmd
- if param != "" {
- cmd = exec.Command(name, param)
- } else {
- cmd = exec.Command(name)
- }
- cmd.Stdout = os.Stdout
- cmd.Stderr = os.Stderr
- if err := cmd.Run(); err != nil {
- log.Fatal(err)
- }
- return nil, nil
-}
-
-func main() {
- vm := wren.NewVM()
- fileName := "Execute_a_system_command.wren"
- methodMap := wren.MethodMap{"static exec(_,_)": execCommand}
- classMap := wren.ClassMap{"Command": wren.NewClass(nil, nil, methodMap)}
- module := wren.NewModule(classMap)
- vm.SetModule(fileName, module)
- vm.InterpretFile(fileName)
- vm.Free()
-}
diff --git a/Task/Execute-a-system-command/Wren/execute-a-system-command.wren b/Task/Execute-a-system-command/Wren/execute-a-system-command.wren
new file mode 100644
index 0000000000..1d97b0a9de
--- /dev/null
+++ b/Task/Execute-a-system-command/Wren/execute-a-system-command.wren
@@ -0,0 +1,5 @@
+import "os" for Process
+
+Process.exec("ls", ["-lt"])
+System.print()
+Process.exec("dir")
diff --git a/Task/Extreme-floating-point-values/Uiua/extreme-floating-point-values.uiua b/Task/Extreme-floating-point-values/Uiua/extreme-floating-point-values.uiua
new file mode 100644
index 0000000000..d9ae4f444f
--- /dev/null
+++ b/Task/Extreme-floating-point-values/Uiua/extreme-floating-point-values.uiua
@@ -0,0 +1,4 @@
+&p∞
+&p¯∞
+&p¯0 # Distinct value from "0".
+&pNaN # IEEE 754-2008's NaN
diff --git a/Task/Factorial/Haskell/factorial-10.hs b/Task/Factorial/Haskell/factorial-10.hs
new file mode 100644
index 0000000000..d7507d16b3
--- /dev/null
+++ b/Task/Factorial/Haskell/factorial-10.hs
@@ -0,0 +1,8 @@
+-- product of [a,a+1..b]
+productFromTo a b =
+ if a>b then 1
+ else if a == b then a
+ else productFromTo a c * productFromTo (c+1) b
+ where c = (a+b) `div` 2
+
+factorial = productFromTo 1
diff --git a/Task/Factorial/Haskell/factorial-5.hs b/Task/Factorial/Haskell/factorial-5.hs
index 6b76b69b6e..f036c73a77 100644
--- a/Task/Factorial/Haskell/factorial-5.hs
+++ b/Task/Factorial/Haskell/factorial-5.hs
@@ -1,3 +1 @@
-factorial :: Integral -> Integral
-factorial 0 = 1
-factorial n = n * factorial (n-1)
+factorials = 1 : zipWith (*) factorials [1..]
diff --git a/Task/Factorial/Haskell/factorial-6.hs b/Task/Factorial/Haskell/factorial-6.hs
index baef906bf8..655c366a44 100644
--- a/Task/Factorial/Haskell/factorial-6.hs
+++ b/Task/Factorial/Haskell/factorial-6.hs
@@ -1,5 +1,2 @@
-fac n
- | n >= 0 = go 1 n
- | otherwise = error "Negative factorial!"
- where go acc 0 = acc
- go acc n = go (acc * n) (n - 1)
+factorials = go 1 1 where
+ go n fac = f : go (n+1) (n*fac)
diff --git a/Task/Factorial/Haskell/factorial-7.hs b/Task/Factorial/Haskell/factorial-7.hs
index 77d34e9b2e..6b76b69b6e 100644
--- a/Task/Factorial/Haskell/factorial-7.hs
+++ b/Task/Factorial/Haskell/factorial-7.hs
@@ -1,10 +1,3 @@
-{-# LANGUAGE PostfixOperators #-}
-
-(!) :: Integer -> Integer
-(!) 0 = 1
-(!) n = n * (pred n !)
-
-main :: IO ()
-main = do
- print (5 !)
- print ((4 !) !)
+factorial :: Integral -> Integral
+factorial 0 = 1
+factorial n = n * factorial (n-1)
diff --git a/Task/Factorial/Haskell/factorial-8.hs b/Task/Factorial/Haskell/factorial-8.hs
index d7507d16b3..baef906bf8 100644
--- a/Task/Factorial/Haskell/factorial-8.hs
+++ b/Task/Factorial/Haskell/factorial-8.hs
@@ -1,8 +1,5 @@
--- product of [a,a+1..b]
-productFromTo a b =
- if a>b then 1
- else if a == b then a
- else productFromTo a c * productFromTo (c+1) b
- where c = (a+b) `div` 2
-
-factorial = productFromTo 1
+fac n
+ | n >= 0 = go 1 n
+ | otherwise = error "Negative factorial!"
+ where go acc 0 = acc
+ go acc n = go (acc * n) (n - 1)
diff --git a/Task/Factorial/Haskell/factorial-9.hs b/Task/Factorial/Haskell/factorial-9.hs
new file mode 100644
index 0000000000..77d34e9b2e
--- /dev/null
+++ b/Task/Factorial/Haskell/factorial-9.hs
@@ -0,0 +1,10 @@
+{-# LANGUAGE PostfixOperators #-}
+
+(!) :: Integer -> Integer
+(!) 0 = 1
+(!) n = n * (pred n !)
+
+main :: IO ()
+main = do
+ print (5 !)
+ print ((4 !) !)
diff --git a/Task/Factorial/Langur/factorial-1.langur b/Task/Factorial/Langur/factorial-1.langur
index 607783ad36..8f10a78690 100644
--- a/Task/Factorial/Langur/factorial-1.langur
+++ b/Task/Factorial/Langur/factorial-1.langur
@@ -1,2 +1,2 @@
-val factorial = fn n: fold(fn{*}, 2 .. n)
+val factorial = fn n: fold(2 .. n, by=fn{*})
writeln factorial(7)
diff --git a/Task/Factorial/M2000-Interpreter/factorial.m2000 b/Task/Factorial/M2000-Interpreter/factorial-1.m2000
similarity index 100%
rename from Task/Factorial/M2000-Interpreter/factorial.m2000
rename to Task/Factorial/M2000-Interpreter/factorial-1.m2000
diff --git a/Task/Factorial/M2000-Interpreter/factorial-2.m2000 b/Task/Factorial/M2000-Interpreter/factorial-2.m2000
new file mode 100644
index 0000000000..dc7940cef8
--- /dev/null
+++ b/Task/Factorial/M2000-Interpreter/factorial-2.m2000
@@ -0,0 +1,27 @@
+Cls , 0 ' 0 for non split display, eg 3 means we preserve the 3 top lines from scrolling/cla
+Report {
+ Factorial Task
+ Definitions
+ • The factorial of 0 (zero) is defined as being 1 (unity).
+ • The Factorial Function of a positive integer, n, is defined as the product of the sequence:
+ n, n-1, n-2, ... 1
+
+}
+Cls, row ' now we preserve some lines (as row number return here)
+Module CheckIt {
+ m=bigInteger("1")
+ with m, "tostring" as m.toString
+ k=width-tab
+ For i=1 to 1000
+ if pos>tab then print
+ Print @(0), format$("{0::-4} :", i) ;
+ method m,"multiply", biginteger(i+"") as m
+ Report m.toString, k
+ ' Report stop at 2/3 of display lines, and wait mouse button or spacebar
+ ' we can flush the keyboard buffer and press space, so we get non stop display
+ ' Report didn't stop if we use the printer's layer.
+ while inkey$<>"": wait 1:end while
+ keyboard " "
+ Next i
+}
+Checkit
diff --git a/Task/Factorial/Retro/factorial.retro b/Task/Factorial/Retro/factorial.retro
index fb56673ef4..11cf76e297 100644
--- a/Task/Factorial/Retro/factorial.retro
+++ b/Task/Factorial/Retro/factorial.retro
@@ -1,2 +1,8 @@
-: dup 1 = if; dup 1- * ;
-: factorial dup 0 = [ 1+ ] [ ] if ;
+:
+ dup #1 -eq? 0; drop
+ dup n:dec * ;
+
+:factorial
+ dup n:zero?
+ [ n:inc ]
+ [ ] choose ;
diff --git a/Task/Factorial/YAMLScript/factorial.ys b/Task/Factorial/YAMLScript/factorial.ys
index b823037a90..06c6ba6aef 100644
--- a/Task/Factorial/YAMLScript/factorial.ys
+++ b/Task/Factorial/YAMLScript/factorial.ys
@@ -1,4 +1,4 @@
-!yamlscript/v0
+!YS-v0
defn main(n=10):
say: "$n! -> $factorial(n)"
diff --git a/Task/Factors-of-an-integer/EDSAC-order-code/factors-of-an-integer.edsac b/Task/Factors-of-an-integer/EDSAC-order-code/factors-of-an-integer.edsac
index cdf4742401..75f73ed6fb 100644
--- a/Task/Factors-of-an-integer/EDSAC-order-code/factors-of-an-integer.edsac
+++ b/Task/Factors-of-an-integer/EDSAC-order-code/factors-of-an-integer.edsac
@@ -1,153 +1,151 @@
- [Factors of an integer, from Rosetta Code website.]
- [EDSAC program, Initial Orders 2.]
+[Factors of an integer, from Rosetta Code website.]
+[EDSAC program, Initial Orders 2.]
+[2024-12-25 (1) Fixed bug in print subroutine
+ (2) Added factors of more integers.
[The numbers to be factorized are read in by library subroutine R2
(Wilkes, Wheeler and Gill, 1951 edition, pp.96-97, 148).]
[The address of the integers is placed in location 46, so they can be
referred to by the N parameter (or we could have used 45 and H, etc.)]
- T 46 K
- P 600 F [address of integers]
+ T46K
+ P600F [address of integers]
[Subroutine R2]
GKT20FVDL8FA40DUDTFI40FA40FS39FG@S2FG23FA5@T5@E4@E13Z
- T #N [pass address of integers to R2]
+ T#N [pass address of integers to R2]
+[Integers, separated by 'F' and terminated by '#TZ', as R2 requires.]
+420F42000F420000F99999F999999F0#
+ TZ [resume normal loading]
-[List of integers to be factorized; edit ad lib. R2 requires 'F' after
- each integer except the last, and '#' (pi) after the last.
- This program uses 0 to mark the end of the list.]
- 42000F999999F0#
- T Z [resume normal loading]
+ [Modified library subroutine P7.
+ Prints signed integer; up to 10 digits, left-justified.
+ Input: 0D = integer
+ 52 locations. Load at even address. Workspace 4D.]
+ T56K
+GKA3FT42@A47@T31@ADE10@T31@A46@T31@SDTDH44#@NDYFLDT4DS43@TF
+H17@S17@A43@G23@UFS43@T1FV4DAFG48@SFLDUFXFOFFFSFL4FT4DA47@
+T31@A1FA43@G20@XFT44#ZPFT43ZP1024FP610D@524DO26@XFSFL8FT4DE39@
- [Modified library subroutine P7.]
- [Prints signed integer; up to 10 digits, left-justified.]
- [Input: 0D = integer,]
- [54 locations. Load at even address. Workspace 4D.]
- T 56 K
-GKA3FT42@A49@T31@ADE10@T31@A48@T31@SDTDH44#@NDYFLDT4DS43@
-TFH17@S17@A43@G23@UFS43@T1FV4DAFG50@SFLDUFXFOFFFSFL4FT4DA49@
-T31@A1FA43@G20@XFP1024FP610D@524D!FO46@O26@XFSFL8FT4DE39@
-
- [Division subroutine for positive long integers.
- 35-bit dividend and divisor (max 2^34 - 1)
- returning quotient and remainder.
- Input: dividend at 4D, divisor at 6D
- Output: remainder at 4D, quotient at 6D.
- 37 locations; working locations 0D, 8D.]
- T 110 K
+ [Division subroutine for positive long integers.
+ 35-bit dividend and divisor (max 2^34 - 1)
+ returning quotient and remainder.
+ Input: dividend at 4D, divisor at 6D
+ Output: remainder at 4D, quotient at 6D.
+ 37 locations; working locations 0D, 8D.]
+ T110K
GKA3FT35@A6DU8DTDA4DRDSDG13@T36@ADLDE4@T36@T6DA4DSDG23@
T4DA6DYFYFT6DT36@A8DSDE35@T36@ADRDTDA6DLDT6DE15@EFPF
[********************** ROSETTA CODE TASK **********************]
- [Subroutine to find and print factors of a positive integer.
- Input: 0D = integer, maximum 10 decimal digits.
- Load at even address.]
- T 148 K
- G K
- A 3 F [form and plant link for return]
- T 55 @
- A D [load integer whose factors are to be found]
- T 56#@ [store]
- A 62#@ [load 1]
- T 58#@ [possible factor := 1]
- S 65 @ [negative count of items per line]
- T 64 @ [initialize count]
+ [Subroutine to find and print factors of a positive integer.
+ Input: 0D = integer, maximum 10 decimal digits.
+ Load at even address.]
+ T148K
+ GK
+ A3F [form and plant link for return]
+ T55@
+ AD [load integer whose factors are to be found]
+ T56#@ [store]
+ A62#@ [load 1]
+ T58#@ [possible factor := 1]
+ S65@ [negative count of items per line]
+ T64@ [initialize count]
[Start of loop round possible factors]
- [8] T F [clear acc]
- A 56#@ [load integer]
- T 4 D [to 4F for division]
- A 58#@ [load possible factor]
- T 6 D [to 6F for division]
- A 13 @ [for return from next]
- G 110 F [do division; clears acc]
- A 6 D [save quotient (6F may be changed below)]
- T 60#@
- S 4 D [load negative of remainder]
- G 44 @ [skip if remainder > 0]
+ [8] TF [clear acc]
+ A56#@ [load integer]
+ T4D [to 4D for division]
+ A58#@ [load possible factor]
+ T6D [to 6D for division]
+ A13@ [for return from next]
+ G110F [do division; clears acc]
+ A6D [save quotient (6D may be changed below)]
+ T60#@
+ S4D [load negative of remainder]
+ G44@ [skip if remainder > 0]
[Here if m is a factor of n.]
[Print m and the quotient together]
- T F [clear acc]
- A 64 @ [test count of items per line]
- G 26 @ [skip if not start of line]
- S 65 @ [start of line, reset count]
- T 64 @
- O 70 @ [and print CR, LF]
- O 71 @
- [26] T F [clear acc]
- O 67 @ [print '(']
- A 58#@ [load factor]
- T D [to 0D for printing]
- A 30 @ [for return from next]
- G 56 F [print factor; clears acc]
- O 69 @ [print comma]
- A 60#@ [load quotient]
- T D [to 0D for printing]
- A 35 @ [for return from next]
- G 56 F [print quotient; clears acc]
- O 68 @ [print ')']
- A 64 @ [negative counter for items per line]
- A 2 F [inc]
- E 43 @ [skip if end of line]
- O 66 @ [not end of line, print 2 spaces]
- O 66 @
- [43] T 64 @ [update counter]
+ TF [clear acc]
+ A64@ [test count of items per line]
+ G26@ [skip if not start of line]
+ S65@ [start of line, reset count]
+ T64@
+ O70@ [and print CR, LF]
+ O71@
+ [26] TF [clear acc]
+ O67@ [print '(']
+ A58#@ [load factor]
+ TD [to 0D for printing]
+ A30@ [for return from next]
+ G56F [print factor; clears acc]
+ O69@ [print comma]
+ A60#@ [load quotient]
+ TD [to 0D for printing]
+ A35@ [for return from next]
+ G56F [print quotient; clears acc]
+ O68@ [print ')']
+ A64@ [negative counter for items per line]
+ A2F [inc]
+ E43@ [skip if end of line]
+ O66@ [not end of line, print 2 spaces]
+ O66@
+ [43] T64@ [update counter]
[Common code after testing possible factor]
- [44] T F [clear acc]
- A 58#@ [load possible factor]
- A 62#@ [inc by 1]
- U 58#@ [store back]
- S 60#@ [compare with quotient]
- G 8 @ [loop if (new factor) < (old quotient)]
+ [44] TF [clear acc]
+ A58#@ [load possible factor]
+ A62#@ [inc by 1]
+ U58#@ [store back]
+ S60#@ [compare with quotient]
+ G8@ [loop if (new factor) < (old quotient)]
[Here when found all factors]
- O 70 @ [print CR, LF twice]
- O 71 @
- O 70 @
- O 71 @
- T F [exit with acc = 0]
- [55] E F [return]
- [--------]
- [56] PF PF [number whose factors are to be found]
- [58] PF PF [possible factor]
- [60] PF PF [integer part of (number/factor)]
- T62#Z PF [clear sandwich digit in 35-bit constant 1]
- T 62 Z [resume normal loading]
- [62] PD PF [35-bit constant 1]
- [64] P F [negative counter for items per line]
- [65] P 4 F [items per line, in address field]
- [66] ! F [space]
- [67] K F [left parenthesis (in figures mode)]
- [68] L F [right parenthesis (in figures mode)]
- [69] N F [comma (in figures mode)]
- [70] @ F [carriage return]
- [71] & F [line feed]
+ O70@ [print CR, LF twice]
+ O71@
+ O70@
+ O71@
+ TF [exit with acc = 0]
+ [55] EF [(planted) return to caller]
+ [--------------]
+ [56] PF PF [number whose factors are to be found]
+ [58] PF PF [possible factor]
+ [60] PF PF [integer part of (number/factor)]
+ T62#Z [clear whole of 35-bit constant, including sandwich bit]
+ PF
+ T62Z [resume normal loading]
+ [62] PD PF [35-bit constant 1]
+ [64] PF [negative counter for items per line]
+ [65] P4F [items per line, in address field]
+ [66] !F [space]
+ [67] KF
+ [68] LF
+ [69] NF [comma, in figure shift]
+ [70] @F [carriage return]
+ [71] &F [line feed]
[Main routine for demonstrating subroutine.]
- T 400 K
- G K
- [0] # F [set figures mode]
- [1] K 4096 F [null char]
- [2] S #N [order to load negative of first number]
- [3] P 2 F [to inc address by 2 for next number]
+ T400K
+ GK
+ [0] #F [figure shift]
+ [1] K4096F [null char]
+ [2] S#N [order to load negative first number]
+ [3] P2F [to inc address by 2 for next number]
[Enter with acc = 0]
- [4] O @ [set teleprinter to figures]
- A 2 @ [load order for first integer]
- [6] T 7 @ [plant in next order]
- [7] S D [load negative of 35-bit integer]
- E 17 @ [exit if number is 0]
- T D [negative to 0D]
- S D [convert to positive]
- T D [pass to subroutine]
- A 12 @ [call subroutine to find and print factors]
- G 148 F
- A 7 @ [modify order above, for next integer]
- A 3 @
- E 6 @ [always jump, since S = 12 > 0]
- [--------]
- [17] O 1 @ [done, print null to flush printer buffer]
- Z F [stop]
-
- E 4 Z [define entry point]
- P F [acc = 0 on entry]
+ [4] O@ [set teleprinter to figures]
+ A2@ [load order for first integer]
+ [6] T7@ [plant in next order]
+ [7] SD [load negative of 35-bit integer]
+ E17@ [exit if number is 0]
+ TD
+ SD [convert to positive]
+ TD [pass to subroutine]
+ A12@ [call subroutine to find and print factors]
+ G148F
+ A7@ [modify order above, for next integer]
+ A3@
+ E6@ [always jump, since S = 12 > 0]
+ [17] O1@ [done, print null to flush printer buffer]
+ ZF [stop]
+ E4Z [define entry point]
+ PF [acc = 0 on entry
diff --git a/Task/Factors-of-an-integer/FutureBasic/factors-of-an-integer.basic b/Task/Factors-of-an-integer/FutureBasic/factors-of-an-integer.basic
index d8d5b31d8b..5ceb9204b8 100644
--- a/Task/Factors-of-an-integer/FutureBasic/factors-of-an-integer.basic
+++ b/Task/Factors-of-an-integer/FutureBasic/factors-of-an-integer.basic
@@ -1,50 +1,23 @@
-window 1, @"Factors of an Integer", (0,0,1000,270)
+local fn Factors( n as int ) as CFArrayRef
+ CFMutableArrayRef mutArray = fn MutableArrayNew
-clear local mode
-local fn IntegerFactors( f as long ) as CFStringRef
- long i, s, l(100), c = 0
- CFStringRef factorStr = @""
-
- for i = 1 to sqr(f)
- if ( f mod i == 0 )
- l(c) = i
- c++
- if ( f != i ^ 2 )
- l(c) = ( f / i )
- c++
+ for int factor = 1 to sqr(n)
+ if ( n mod factor == 0 )
+ MutableArrayAddObject( mutArray, @(factor) )
+ if ( n/factor != factor )
+ MutableArrayAddObject( mutArray, @(n/factor) )
end if
end if
- next i
-
- s = 1
- while ( s = 1 )
- s = 0
- for i = 0 to c-1
- if l(i) > l(i+1) and l(i+1) != 0
- swap l(i), l(i+1)
- s = 1
- end if
- next i
- wend
-
- for i = 0 to c - 1
- if ( i < c - 1 )
- factorStr = fn StringWithFormat( @"%@ %ld, ", factorStr, l(i) )
- else
- factorStr = fn StringWithFormat( @"%@ %ld", factorStr, l(i) )
- end if
next
-end fn = factorStr
+ CFArrayRef result = fn ArraySortedArrayUsingSelector( mutArray, @"compare:" )
+end fn = result
-print @"Factors of 25 are:"; fn IntegerFactors( 25 )
-print @"Factors of 45 are:"; fn IntegerFactors( 45 )
-print @"Factors of 103 are:"; fn IntegerFactors( 103 )
-print @"Factors of 760 are:"; fn IntegerFactors( 760 )
-print @"Factors of 12345 are:"; fn IntegerFactors( 12345 )
-print @"Factors of 32766 are:"; fn IntegerFactors( 32766 )
-print @"Factors of 32767 are:"; fn IntegerFactors( 32767 )
-print @"Factors of 57097 are:"; fn IntegerFactors( 57097 )
-print @"Factors of 12345678 are:"; fn IntegerFactors( 12345678 )
-print @"Factors of 32434243 are:"; fn IntegerFactors( 32434243 )
+mda (0) = {1,2,3,4,5,6,7,8,9,10,20,40,60,80,100,200,300,400,512,677,768,966,1000,1024,2048,4096}
+
+int i, n
+for i = 0 to mda_count -1
+ n = mda_integer(i)
+ print fn StringWithFormat( @"Factors of %4d: [%@]", n, fn ArrayComponentsJoinedByString( fn Factors( n ), @", " ) )
+next
HandleEvents
diff --git a/Task/Factors-of-an-integer/Raku/factors-of-an-integer.raku b/Task/Factors-of-an-integer/Raku/factors-of-an-integer-1.raku
similarity index 100%
rename from Task/Factors-of-an-integer/Raku/factors-of-an-integer.raku
rename to Task/Factors-of-an-integer/Raku/factors-of-an-integer-1.raku
diff --git a/Task/Factors-of-an-integer/Raku/factors-of-an-integer-2.raku b/Task/Factors-of-an-integer/Raku/factors-of-an-integer-2.raku
new file mode 100644
index 0000000000..ae8b49d375
--- /dev/null
+++ b/Task/Factors-of-an-integer/Raku/factors-of-an-integer-2.raku
@@ -0,0 +1,5 @@
+use Prime::Factor;
+
+put divisors :s, 2⁹⁹ + 1;
+
+say (now - INIT now).round(.001) ~' seconds';
diff --git a/Task/Farey-sequence/Langur/farey-sequence.langur b/Task/Farey-sequence/Langur/farey-sequence.langur
index 2743d7c155..2aa36b46f1 100644
--- a/Task/Farey-sequence/Langur/farey-sequence.langur
+++ b/Task/Farey-sequence/Langur/farey-sequence.langur
@@ -10,7 +10,7 @@ val farey = fn(n) {
val testFarey = fn*() {
writeln "Farey sequence for orders 1 through 11"
for i of 11 {
- writeln "{{i:2}}: ", join(" ", map(fn f: "{{f[1]}}/{{f[2]}}", farey(i)))
+ writeln "{{i:2}}: ", join(map(farey(i), by=fn f: "{{f[1]}}/{{f[2]}}"), by=" ")
}
}
diff --git a/Task/Fast-Fourier-transform/M2000-Interpreter/fast-fourier-transform-1.m2000 b/Task/Fast-Fourier-transform/M2000-Interpreter/fast-fourier-transform-1.m2000
new file mode 100644
index 0000000000..45d054c7f9
--- /dev/null
+++ b/Task/Fast-Fourier-transform/M2000-Interpreter/fast-fourier-transform-1.m2000
@@ -0,0 +1,51 @@
+module CreateLibComplexPack {
+ prototype {
+ class ComplexPack {
+ function final complexPolar(a, b) {
+ method .m, "cxPolar", a, b as ret
+ =ret
+ }
+ function final complex(a, b) {
+ method .m, "cxNew", a, b as ret
+ =ret
+ }
+ function final mul(a, b) {
+ method .m, "cxMul", a, b as ret
+ =ret
+ }
+ function final add(a, b) {
+ method .m, "cxAdd", a, b as ret
+ =ret
+ }
+ function final sub(a, b) {
+ method .m, "cxSub", a, b as ret
+ =ret
+ }
+ Module final FFT(buf, out, begin as Long, stp as Long, N as Long) {
+ If stp < N Then
+ call .FFT, out, buf, begin, 2 * stp, N
+ call .FFT, out, buf, begin + stp, 2 * stp, N
+ var i as long, t as variant
+ for i=0 to N-1 step 2*stp
+ t= .mul(.complexPolar(1, -pi* i / N), out[begin + i + stp])
+ buf[begin + i div 2]= .add(out[begin + i], t)
+ buf[begin + (i + N) div 2]= .sub(out[begin + i], t)
+ next
+ End If
+ }
+ private:
+ declare m math2
+ public:
+ property zero {value}
+ class:
+ module ComplexPack{
+ method .m,"cxzero" as z
+ .[zero]<=z
+ }
+ }
+ } as ComplexPack
+ const UTF8=2&
+ document Export$=ComplexPack
+ Save.Doc Export$, "ComplexPack.gsb", UTF8
+}
+CreateLibComplexPack
diff --git a/Task/Fast-Fourier-transform/M2000-Interpreter/fast-fourier-transform-2.m2000 b/Task/Fast-Fourier-transform/M2000-Interpreter/fast-fourier-transform-2.m2000
new file mode 100644
index 0000000000..aeb97fb834
--- /dev/null
+++ b/Task/Fast-Fourier-transform/M2000-Interpreter/fast-fourier-transform-2.m2000
@@ -0,0 +1,19 @@
+module FFT {
+ load "ComplexPack"
+ cp=ComplexPack()
+ variant buf[7]=cp.zero, out[7]=cp.zero
+ buf[0]|r = 1: buf[1]|r = 1: buf[2]|r = 1: buf[3]|r = 1
+ showArr(buf, "Input")
+ cp.FFT out, buf, 0, 1, 8
+ ShowArr(out, "Output")
+
+ Sub ShowArr(m, mes as string)
+ local n, mx=len(m)
+ Print mes;": (real+imag)"
+ while n")
+ concat("<",vstr(2, Comp,", ",0,-1),"j> ")
#end
#macro CdebugArr(data)
#for(i,0, dimension_size(data, 1)-1)
- #debug concat(Cstr(data[i]), "\n")
+ #debug concat(Cstr(data[i]), " ", str(Abs(data[i]),-1,-1),"\n")
#end
#end
#macro R2C(Real) #end
-#macro CmultC(C1, C2) #end
+#macro CmultC(C1, C2) #end
#macro Conjugate(Comp) #end
@@ -26,6 +26,8 @@ global_settings{ assumed_gamma 1.0 }
bitwise_and((X > 0), (bitwise_and(X, (X - 1)) = 0))
#end
+#macro Abs(C) sqrt(C.x * C.x + C.y * C.y) #end
+
#macro _FFT0(X, Y, N, Stride, EO)
#local M = div(N, 2);
#local Theta = 2 * pi / N;
diff --git a/Task/Fast-Fourier-transform/PascalABC.NET/fast-fourier-transform.pas b/Task/Fast-Fourier-transform/PascalABC.NET/fast-fourier-transform.pas
new file mode 100644
index 0000000000..f6b42e2fa0
--- /dev/null
+++ b/Task/Fast-Fourier-transform/PascalABC.NET/fast-fourier-transform.pas
@@ -0,0 +1,32 @@
+function fft(x: array of complex): array of complex;
+begin
+ var n := x.length;
+ if n = 0 then exit;
+
+ setlength(result, n);
+
+ if n = 1 then
+ begin
+ result[0] := x[0];
+ exit;
+ end;
+
+ var evens := x.Where((x, i) -> i mod 2 = 0).ToArray;
+ var odds := x.Where((x, i) -> i mod 2 = 1).ToArray;
+ var (even, odd) := (fft(evens), fft(odds));
+
+ var halfn := n div 2;
+
+ for var k := 0 to halfn - 1 do
+ begin
+ var a := exp(new Complex(0.0, -2 * Pi * k / n)) * odd[k];
+ result[k] := even[k] + a;
+ result[k + halfn] := even[k] - a;
+ end;
+end;
+
+begin
+ var test := |1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0|;
+ foreach var x in fft(test.select(x -> new Complex(x, 0)).ToArray) do
+ println(x)
+end.
diff --git a/Task/Fast-Fourier-transform/Swift/fast-fourier-transform.swift b/Task/Fast-Fourier-transform/Swift/fast-fourier-transform.swift
index ff86082f2b..aba4575660 100644
--- a/Task/Fast-Fourier-transform/Swift/fast-fourier-transform.swift
+++ b/Task/Fast-Fourier-transform/Swift/fast-fourier-transform.swift
@@ -5,7 +5,7 @@ typealias Complex = Numerics.Complex
extension Complex {
var exp: Complex {
- Complex(cos(imaginary), sin(imaginary)) * Complex(cosh(real), sinh(real))
+ Complex(cos(imaginary), sin(imaginary)) * Complex(cosh(real) + sinh(real), 0)
}
var pretty: String {
diff --git a/Task/Fibonacci-n-step-number-sequences/Python/fibonacci-n-step-number-sequences-3.py b/Task/Fibonacci-n-step-number-sequences/Python/fibonacci-n-step-number-sequences-3.py
index fb273a2545..bc445d27d1 100644
--- a/Task/Fibonacci-n-step-number-sequences/Python/fibonacci-n-step-number-sequences-3.py
+++ b/Task/Fibonacci-n-step-number-sequences/Python/fibonacci-n-step-number-sequences-3.py
@@ -1,19 +1,19 @@
from itertools import islice, cycle
-def fiblike(tail):
- for x in tail:
- yield x
- for i in cycle(xrange(len(tail))):
+def fiblike(init_values=(0, 1)):
+ tail = list(init_values)
+ yield from tail
+ for i in cycle(range(len(tail))):
tail[i] = x = sum(tail)
yield x
-fibo = fiblike([1, 1])
-print list(islice(fibo, 10))
+print([*islice(fiblike(), 10)])
lucas = fiblike([2, 1])
-print list(islice(lucas, 10))
+print([*islice(lucas, 10)])
-suffixes = "fibo tribo tetra penta hexa hepta octo nona deca"
-for n, name in zip(xrange(2, 11), suffixes.split()):
- fib = fiblike([1] + [2 ** i for i in xrange(n - 1)])
+suffixes = dict(enumerate('fibo tribo tetra penta hexa hepta octo nona deca'.split(), start=2))
+
+for name, n in suffixes.items():
+ fib = fiblike([1] + [2 ** i for i in range(n-1)])
items = list(islice(fib, 15))
- print "n=%2i, %5snacci -> %s ..." % (n, name, items)
+ print(f'n={n:>2}, {name:>5}nacci -> {items} ...')
diff --git a/Task/Fibonacci-n-step-number-sequences/Python/fibonacci-n-step-number-sequences-5.py b/Task/Fibonacci-n-step-number-sequences/Python/fibonacci-n-step-number-sequences-5.py
new file mode 100644
index 0000000000..d95bd55348
--- /dev/null
+++ b/Task/Fibonacci-n-step-number-sequences/Python/fibonacci-n-step-number-sequences-5.py
@@ -0,0 +1,34 @@
+from itertools import chain
+
+def A000032():
+ '''Non finite sequence of Lucas numbers.
+ '''
+ return unfoldr(recurrence, [0, 1])
+
+def n_step_fibonacci(n):
+ '''Non-finite series of N-step Fibonacci numbers,
+ defined by a recurrence relation.
+ '''
+ return unfoldr(
+ recurrence,
+ chain(
+ (0,),
+ (2 ** i for i in range(0, n-1))))
+
+def recurrence(xs):
+ '''Recurrence relation in Fibonacci and related series.
+ '''
+ h, *t = xs
+ return h, t + [sum(xs)]
+
+def unfoldr(f, residue):
+ '''Generic anamorphism.
+ A lazy (generator) list unfolded from a seed value by
+ repeated application of f until no residue remains.
+ Dual to fold/reduce.
+ f returns either None, or just (value, residue).
+ For a strict output value, wrap in list().
+ '''
+ while residue is not None:
+ value, residue = f(residue)
+ yield value
diff --git a/Task/Fibonacci-n-step-number-sequences/Python/fibonacci-n-step-number-sequences-6.py b/Task/Fibonacci-n-step-number-sequences/Python/fibonacci-n-step-number-sequences-6.py
new file mode 100644
index 0000000000..0de67431c2
--- /dev/null
+++ b/Task/Fibonacci-n-step-number-sequences/Python/fibonacci-n-step-number-sequences-6.py
@@ -0,0 +1,46 @@
+from itertools import chain
+
+def f_rec_tailfail(values=[0, 1], combine=sum):
+ """
+ This fails with `RecursionError: maximum recursion depth exceeded`
+ when the number of consumed elements surpasses maximum stack size
+ (by default 1000 call frames -- `sys.getrecursionlimit()`),
+ due to the fact that Python does not have tail call optimization.
+ """
+ yield values[0]
+ yield from f_rec_tailfail(values[1:] + [combine(values)], combine)
+
+
+def f_rec_gen_func(values=[0, 1], combine=sum):
+ """
+ This function does not suffer from `RecursionError` per se, but stack overflow
+ nevertheless does happen in the underlying C code when too many elements are
+ consumed from the generator.
+
+ One possible reason for this is because `chain` is implemented in C,
+ and the chain consists of another `chain` object, which in turn contains
+ another `chain` object, etc. The effect of this is that all the recursive
+ calls happen on the C call stack (where recursion depth is not checked
+ against the limit), not on the Python call stack. As a result, it is possible
+ to achieve much greater recursion depth -- over 40,000 recursive calls
+ instead of mere 1000. When a stack overflow eventually happens, the Python
+ interpreter crashes quietly without any error message (CPython 3.11.3 AMD64).
+ """
+ def generate_values():
+ yield [values[0]]
+ yield f_rec_gen_func(values[1:] + [combine(values)], combine)
+ return chain.from_iterable(generate_values())
+
+
+def f_rec_gen_lambdas(values=[0, 1], combine=sum):
+ """
+ Similar to `f_rec_gen_func`; also does not suffer from `RecursionError`
+ but crashes when many values are consumed.
+ """
+ return chain.from_iterable(
+ f()
+ for f in (
+ lambda: [values[0]],
+ lambda: f_rec_gen_lambdas(values[1:] + [combine(values)], combine),
+ )
+ )
diff --git a/Task/Fibonacci-n-step-number-sequences/Python/fibonacci-n-step-number-sequences-7.py b/Task/Fibonacci-n-step-number-sequences/Python/fibonacci-n-step-number-sequences-7.py
new file mode 100644
index 0000000000..7889a4ed7b
--- /dev/null
+++ b/Task/Fibonacci-n-step-number-sequences/Python/fibonacci-n-step-number-sequences-7.py
@@ -0,0 +1,35 @@
+from dataclasses import dataclass, field
+from functools import wraps
+from typing import Callable, Generator
+
+GeneratorFunc = Callable[..., Generator]
+
+@dataclass
+class RecursiveCall:
+ args: tuple = ()
+ kwargs: dict = field(default_factory=dict)
+
+def tail_recursive_generator(fun: GeneratorFunc) -> GeneratorFunc:
+ @wraps(fun)
+ def decorated(*args, **kwargs):
+ while True:
+ it = fun(*args, **kwargs)
+ try:
+ while True:
+ yield next(it)
+ except StopIteration as e:
+ if not isinstance(res := e.value, RecursiveCall):
+ return res
+ args, kwargs = res.args, res.kwargs
+
+ return decorated
+
+@tail_recursive_generator
+def f_rec_tail(values=(0, 1), combine=sum):
+ """
+ Does not crash or throw RecursionError! Yay!
+ """
+ yield values[0]
+ # determining why we cannot call `f_rec_tail` directly
+ # is left as an exercise for the reader...
+ return RecursiveCall(args=(values[1:] + (combine(values),), combine))
diff --git a/Task/Fibonacci-sequence/Haskell/fibonacci-sequence-17.hs b/Task/Fibonacci-sequence/Haskell/fibonacci-sequence-17.hs
index 593d8551aa..a2360de226 100644
--- a/Task/Fibonacci-sequence/Haskell/fibonacci-sequence-17.hs
+++ b/Task/Fibonacci-sequence/Haskell/fibonacci-sequence-17.hs
@@ -1,35 +1,17 @@
-import Control.Arrow ((&&&))
+import Data.Ratio (numerator)
-fibstep :: (Integer, Integer) -> (Integer, Integer)
-fibstep (a, b) = (b, a + b)
+infixl 7 *.
+(*.) :: Num a => a -> [a] -> [a]
+x *. (p:ps) = x*p : x*.ps
-fibnums :: [Integer]
-fibnums = map fst $ iterate fibstep (0, 1)
+instance Num a => Num [a] where
+ negate = map negate
+ (+) = zipWith (+)
+ (*) (p:ps) (q:qs) = p*q : ((p*.qs) + ps*(q:qs))
+ fromInteger n = fromInteger n:repeat 0
-fibN2 :: Integer -> (Integer, Integer)
-fibN2 m
- | m < 10 = iterate fibstep (0, 1) !! fromIntegral m
-fibN2 m = fibN2_next (n, r) (fibN2 n)
- where
- (n, r) = quotRem m 3
+instance (Eq a, Fractional a) => Fractional [a] where
+ (/) (0:ps) (0:qs) = ps/qs
+ (/) (p:ps) (q:qs) = let r=p/q in r : (ps - r*.qs)/(q:qs)
-fibN2_next (n, r) (f, g)
- | r == 0 = (a, b) -- 3n ,3n+1
- | r == 1 = (b, c) -- 3n+1,3n+2
- | r == 2 = (c, d) -- 3n+2,3n+3 (*)
- where
- a =
- 5 * f ^ 3 +
- if even n
- then 3 * f
- else (-3 * f) -- 3n
- b = g ^ 3 + 3 * g * f ^ 2 - f ^ 3 -- 3n+1
- c = g ^ 3 + 3 * g ^ 2 * f + f ^ 3 -- 3n+2
- d =
- 5 * g ^ 3 +
- if even n
- then (-3 * g)
- else 3 * g -- 3(n+1) (*)
-
-main :: IO ()
-main = print $ (length &&& take 20) . show . fst $ fibN2 (10 ^ 2)
+ fromRational q = fromRational q:repeat 0
diff --git a/Task/Fibonacci-sequence/Haskell/fibonacci-sequence-18.hs b/Task/Fibonacci-sequence/Haskell/fibonacci-sequence-18.hs
index c69d736bc9..4c4bac3a5c 100644
--- a/Task/Fibonacci-sequence/Haskell/fibonacci-sequence-18.hs
+++ b/Task/Fibonacci-sequence/Haskell/fibonacci-sequence-18.hs
@@ -1,2 +1,3 @@
- *Main> (length &&& take 20) . show . fst $ fibN2 (10^6)
-(208988,"19532821287077577316")
+fibs :: [Integer]
+fibs = map numerator
+ (1/(1 : (-1) : (-1) : repeat 0))
diff --git a/Task/Fibonacci-sequence/Haskell/fibonacci-sequence-19.hs b/Task/Fibonacci-sequence/Haskell/fibonacci-sequence-19.hs
index 7f0a39dbc2..b41a6a08fd 100644
--- a/Task/Fibonacci-sequence/Haskell/fibonacci-sequence-19.hs
+++ b/Task/Fibonacci-sequence/Haskell/fibonacci-sequence-19.hs
@@ -1 +1,2 @@
-f (n,(a,b)) = (2*n,(a*a+b*b,2*a*b+b*b)) -- iterate f (1,(0,1)) ; b is nth
+ghci> take 15 fibs
+[1,1,2,3,5,8,13,21,34,55,89,144,233,377,610]
diff --git a/Task/Fibonacci-sequence/Haskell/fibonacci-sequence-20.hs b/Task/Fibonacci-sequence/Haskell/fibonacci-sequence-20.hs
index dd052ec7a3..ef2e13f1a0 100644
--- a/Task/Fibonacci-sequence/Haskell/fibonacci-sequence-20.hs
+++ b/Task/Fibonacci-sequence/Haskell/fibonacci-sequence-20.hs
@@ -1 +1,8 @@
-g (n,(a,b)) = (2*n,(2*a*b-a*a,a*a+b*b)) -- iterate g (1,(1,1)) ; a is nth
+import Data.Functor.Identity (Identity (..))
+
+fibs :: [Integer]
+fibs = runIdentity (hsequence (repeat f))
+ where f [] = Identity 1
+ f [_] = Identity 1
+ f xs = Identity ((xs !! (i-1)) + (xs !! i))
+ where i = length xs-1
diff --git a/Task/Fibonacci-sequence/Haskell/fibonacci-sequence-21.hs b/Task/Fibonacci-sequence/Haskell/fibonacci-sequence-21.hs
new file mode 100644
index 0000000000..3152e83315
--- /dev/null
+++ b/Task/Fibonacci-sequence/Haskell/fibonacci-sequence-21.hs
@@ -0,0 +1,6 @@
+hsequence :: Monad m => [[x] -> m x] -> m [x]
+hsequence [] = pure []
+hsequence (r:rs) = do
+ x <- r []
+ xs <- hsequence [ \ys -> g (x:ys) | g <- rs ]
+ pure (x:xs)
diff --git a/Task/Fibonacci-sequence/Haskell/fibonacci-sequence-22.hs b/Task/Fibonacci-sequence/Haskell/fibonacci-sequence-22.hs
new file mode 100644
index 0000000000..8340df8cb9
--- /dev/null
+++ b/Task/Fibonacci-sequence/Haskell/fibonacci-sequence-22.hs
@@ -0,0 +1,2 @@
+ghci> take 17 fibs
+[1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987,1597]
diff --git a/Task/Fibonacci-sequence/Haskell/fibonacci-sequence-23.hs b/Task/Fibonacci-sequence/Haskell/fibonacci-sequence-23.hs
new file mode 100644
index 0000000000..593d8551aa
--- /dev/null
+++ b/Task/Fibonacci-sequence/Haskell/fibonacci-sequence-23.hs
@@ -0,0 +1,35 @@
+import Control.Arrow ((&&&))
+
+fibstep :: (Integer, Integer) -> (Integer, Integer)
+fibstep (a, b) = (b, a + b)
+
+fibnums :: [Integer]
+fibnums = map fst $ iterate fibstep (0, 1)
+
+fibN2 :: Integer -> (Integer, Integer)
+fibN2 m
+ | m < 10 = iterate fibstep (0, 1) !! fromIntegral m
+fibN2 m = fibN2_next (n, r) (fibN2 n)
+ where
+ (n, r) = quotRem m 3
+
+fibN2_next (n, r) (f, g)
+ | r == 0 = (a, b) -- 3n ,3n+1
+ | r == 1 = (b, c) -- 3n+1,3n+2
+ | r == 2 = (c, d) -- 3n+2,3n+3 (*)
+ where
+ a =
+ 5 * f ^ 3 +
+ if even n
+ then 3 * f
+ else (-3 * f) -- 3n
+ b = g ^ 3 + 3 * g * f ^ 2 - f ^ 3 -- 3n+1
+ c = g ^ 3 + 3 * g ^ 2 * f + f ^ 3 -- 3n+2
+ d =
+ 5 * g ^ 3 +
+ if even n
+ then (-3 * g)
+ else 3 * g -- 3(n+1) (*)
+
+main :: IO ()
+main = print $ (length &&& take 20) . show . fst $ fibN2 (10 ^ 2)
diff --git a/Task/Fibonacci-sequence/Haskell/fibonacci-sequence-24.hs b/Task/Fibonacci-sequence/Haskell/fibonacci-sequence-24.hs
new file mode 100644
index 0000000000..c69d736bc9
--- /dev/null
+++ b/Task/Fibonacci-sequence/Haskell/fibonacci-sequence-24.hs
@@ -0,0 +1,2 @@
+ *Main> (length &&& take 20) . show . fst $ fibN2 (10^6)
+(208988,"19532821287077577316")
diff --git a/Task/Fibonacci-sequence/Haskell/fibonacci-sequence-25.hs b/Task/Fibonacci-sequence/Haskell/fibonacci-sequence-25.hs
new file mode 100644
index 0000000000..7f0a39dbc2
--- /dev/null
+++ b/Task/Fibonacci-sequence/Haskell/fibonacci-sequence-25.hs
@@ -0,0 +1 @@
+f (n,(a,b)) = (2*n,(a*a+b*b,2*a*b+b*b)) -- iterate f (1,(0,1)) ; b is nth
diff --git a/Task/Fibonacci-sequence/Haskell/fibonacci-sequence-26.hs b/Task/Fibonacci-sequence/Haskell/fibonacci-sequence-26.hs
new file mode 100644
index 0000000000..dd052ec7a3
--- /dev/null
+++ b/Task/Fibonacci-sequence/Haskell/fibonacci-sequence-26.hs
@@ -0,0 +1 @@
+g (n,(a,b)) = (2*n,(2*a*b-a*a,a*a+b*b)) -- iterate g (1,(1,1)) ; a is nth
diff --git a/Task/Fibonacci-sequence/Langur/fibonacci-sequence.langur b/Task/Fibonacci-sequence/Langur/fibonacci-sequence.langur
index 1eaa61b5f6..9db6f35cd7 100644
--- a/Task/Fibonacci-sequence/Langur/fibonacci-sequence.langur
+++ b/Task/Fibonacci-sequence/Langur/fibonacci-sequence.langur
@@ -1,3 +1,3 @@
val fibonacci = fn x:if(x < 2: x ; fn((x - 1)) + fn((x - 2)))
-writeln map(fibonacci, series(2..20))
+writeln map(series(2..20), by=fibonacci)
diff --git a/Task/Fibonacci-sequence/Python/fibonacci-sequence-14.py b/Task/Fibonacci-sequence/Python/fibonacci-sequence-14.py
index 5e6109260b..9ef20e2594 100644
--- a/Task/Fibonacci-sequence/Python/fibonacci-sequence-14.py
+++ b/Task/Fibonacci-sequence/Python/fibonacci-sequence-14.py
@@ -1,8 +1,6 @@
'''Fibonacci accumulation'''
-from itertools import accumulate, chain
-from operator import add
-
+from itertools import accumulate
# fibs :: Integer :: [Integer]
def fibs(n):
@@ -10,22 +8,16 @@ def fibs(n):
the Fibonacci series. The accumulator is a
pair of the two preceding numbers.
'''
- def go(ab, _):
- return ab[1], add(*ab)
-
- return [xy[1] for xy in accumulate(
- chain(
- [(0, 1)],
- range(1, n)
- ),
- go
- )]
+ return [
+ a
+ for a, b in accumulate(
+ range(1, n), # we don't actually use these numbers
+ lambda acc, _: (acc[1], sum(acc)),
+ initial = (0, 1)
+ )
+ ]
# MAIN ---
if __name__ == '__main__':
- print(
- 'First twenty: ' + repr(
- fibs(20)
- )
- )
+ print(f'First twenty: {fibs(20)}')
diff --git a/Task/Fibonacci-sequence/Python/fibonacci-sequence-15.py b/Task/Fibonacci-sequence/Python/fibonacci-sequence-15.py
index 9da8f6a398..7cd4d0fa62 100644
--- a/Task/Fibonacci-sequence/Python/fibonacci-sequence-15.py
+++ b/Task/Fibonacci-sequence/Python/fibonacci-sequence-15.py
@@ -1,21 +1,18 @@
'''Nth Fibonacci term (by folding)'''
from functools import reduce
-from operator import add
-
# nthFib :: Integer -> Integer
def nthFib(n):
'''Nth integer in the Fibonacci series.'''
- def go(ab, _):
- return ab[1], add(*ab)
- return reduce(go, range(1, n), (0, 1))[1]
+ return reduce(
+ lambda acc, _: (acc[1], sum(acc)),
+ range(1, n),
+ (0, 1)
+ )[0]
# MAIN ---
if __name__ == '__main__':
- print(
- '1000th term: ' + repr(
- nthFib(1000)
- )
- )
+ n = 1000
+ print(f'{n}th term: {nthFib(n)}')
diff --git a/Task/Fibonacci-sequence/Python/fibonacci-sequence-18.py b/Task/Fibonacci-sequence/Python/fibonacci-sequence-18.py
deleted file mode 100644
index 4f15e0818e..0000000000
--- a/Task/Fibonacci-sequence/Python/fibonacci-sequence-18.py
+++ /dev/null
@@ -1,7 +0,0 @@
-fi1=fi2=fi3=1 # FIB Russia rextester.com/FEEJ49204
-for da in range(1, 88): # Danilin
- print("."*(20-len(str(fi3))), end=' ')
- print(fi3)
- fi3 = fi2+fi1
- fi1 = fi2
- fi2 = fi3
diff --git a/Task/Fibonacci-sequence/YAMLScript/fibonacci-sequence.ys b/Task/Fibonacci-sequence/YAMLScript/fibonacci-sequence.ys
index d15ba93346..c3c49b69b6 100644
--- a/Task/Fibonacci-sequence/YAMLScript/fibonacci-sequence.ys
+++ b/Task/Fibonacci-sequence/YAMLScript/fibonacci-sequence.ys
@@ -1,4 +1,4 @@
-!yamlscript/v0
+!YS-v0
defn main(n=10):
loop a 0, b 1, i 1:
diff --git a/Task/Fibonacci-word/Forth/fibonacci-word.fth b/Task/Fibonacci-word/Forth/fibonacci-word.fth
new file mode 100644
index 0000000000..b5cf419abc
--- /dev/null
+++ b/Task/Fibonacci-word/Forth/fibonacci-word.fth
@@ -0,0 +1,36 @@
+: .fibword ( n -- )
+ dup case
+ 0 of drop ." 1" endof
+ 1 of drop ." 0" endof
+ dup 1- recurse
+ 2 - recurse
+ endcase ;
+
+fvariable ilog2
+1e 2e fln f/ ilog2 f!
+
+: flog2 ( r -- r )
+ fdup f0<> if
+ fln ilog2 f@ f*
+ then ;
+
+: entropy ( n1 n2 -- r )
+ 2dup + s>f s>f fover f/ fswap s>f fswap f/
+ fdup flog2 f* fswap fdup flog2 f* f+
+ fnegate ;
+
+: main
+ ." N Length Entropy Word" cr
+ 1 0
+ 37 0 do
+ i 1+ 2 .r
+ 2dup + 10 .r space
+ 2dup entropy 17 15 1 f.rdp space
+ i 9 < if i .fibword else ." ..." then
+ cr
+ tuck +
+ loop
+ 2drop ;
+
+main
+bye
diff --git a/Task/Fibonacci-word/FutureBasic/fibonacci-word.basic b/Task/Fibonacci-word/FutureBasic/fibonacci-word.basic
new file mode 100644
index 0000000000..c54549850e
--- /dev/null
+++ b/Task/Fibonacci-word/FutureBasic/fibonacci-word.basic
@@ -0,0 +1,69 @@
+include "NSLog.incl"
+
+begin globals
+ CFStringRef cur, nex
+end globals
+
+
+CFStringRef local fn Increment
+ CFStringRef ret = cur
+ cur = nex
+ nex = fn StringWithFormat( @"%@%@", ret, nex )
+end fn = ret
+
+double local fn GetEntropy( s as CFArrayRef )
+ double entropy = 0.0
+ double hist(256)
+ NSUInteger i
+
+ for i = 0 to 255
+ hist(i)= 0
+ next
+
+ for CFNumberRef num in s
+ hist( fn NumberIntegerValue(num) ) += 1
+ next
+
+ for i = 0 to 255
+ if ( hist(i) > 0 )
+ double rat = hist(i) / fn ArrayCount( s )
+ entropy -= rat * log2(rat)
+ end if
+ next
+ return entropy
+end fn = 0.0
+
+CFStringRef local fn ReverseString( string as CFStringRef )
+ CFMutableStringRef reversedStr = fn MutableStringNew
+ for NSInteger i = len(string) - 1 to 0 step -1
+ MutableStringAppendString( reversedStr, fn StringWithFormat( @"%c", fn StringCharacterAtIndex( string, i ) ) )
+ next
+end fn = reversedStr
+
+local fn DoIt
+ cur = @"1"
+ nex = @"0"
+
+ NSLog( @"%5s %10s %11s %33s", "No.", "Length", "Entrophy", "Binary Fibonacci Word" )
+ CFTimeInterval t = fn CACurrentMediaTime
+ for int i = 0 to 36
+ CFStringRef string = fn Increment
+ CFMutableArrayRef asciiValues = fn MutableArrayNew
+ for NSUInteger j = 0 to len(string) - 1
+ unichar character = fn StringCharacterAtIndex( string, j )
+ MutableArrayAddObject( asciiValues, @(character) )
+ next
+ double ent = fn GetEntropy( asciiValues )
+
+ if ( i <= 10 )
+ NSLog( @"%3d. %9lu %19.15f %@", i+1, (unsigned long)len(string), ent, fn ReverseString( string ) )
+ else
+ NSLog( @"%3d. %9lu %19.15f [length exceeds task limits]", i+1, (unsigned long)len(string), ent )
+ end if
+ next
+ NSLog( @"\nCompute time: %.3f ms",(fn CACurrentMediaTime-t) * 1000 )
+end fn
+
+fn DoIt
+
+HandleEvents
diff --git a/Task/File-input-output/Zig/file-input-output.zig b/Task/File-input-output/Zig/file-input-output.zig
index 877fcc1dfb..8dac331546 100644
--- a/Task/File-input-output/Zig/file-input-output.zig
+++ b/Task/File-input-output/Zig/file-input-output.zig
@@ -1,20 +1,19 @@
const std = @import("std");
-pub fn main() (error{OutOfMemory} || std.fs.File.OpenError || std.fs.File.ReadError || std.fs.File.WriteError)!void {
+pub fn main() !void {
var gpa: std.heap.GeneralPurposeAllocator(.{}) = .{};
defer _ = gpa.deinit();
const allocator = gpa.allocator();
const cwd = std.fs.cwd();
- var input_file = try cwd.openFile("input.txt", .{ .mode = .read_only });
+ var input_file = try cwd.openFile("input.txt", .{});
defer input_file.close();
var output_file = try cwd.createFile("output.txt", .{});
defer output_file.close();
- // Restrict input_file's size to "up to 10 MiB".
- var input_file_content = try input_file.readToEndAlloc(allocator, 10 * 1024 * 1024);
+ const input_file_content = try input_file.readToEndAlloc(allocator, (try input_file.stat()).size);
defer allocator.free(input_file_content);
try output_file.writeAll(input_file_content);
diff --git a/Task/Filter/Langur/filter.langur b/Task/Filter/Langur/filter.langur
index 330dbc2ec2..de22c6a4a2 100644
--- a/Task/Filter/Langur/filter.langur
+++ b/Task/Filter/Langur/filter.langur
@@ -1,4 +1,4 @@
val zlist = series(7)
writeln " list: ", zlist
-writeln "filtered: ", filter(fn{div 2}, zlist)
+writeln "filtered: ", filter(zlist, by=fn{div 2})
diff --git a/Task/Find-if-a-point-is-within-a-triangle/EasyLang/find-if-a-point-is-within-a-triangle.easy b/Task/Find-if-a-point-is-within-a-triangle/EasyLang/find-if-a-point-is-within-a-triangle.easy
index da4b66fced..f57bc5c2a7 100644
--- a/Task/Find-if-a-point-is-within-a-triangle/EasyLang/find-if-a-point-is-within-a-triangle.easy
+++ b/Task/Find-if-a-point-is-within-a-triangle/EasyLang/find-if-a-point-is-within-a-triangle.easy
@@ -1,3 +1,10 @@
+ax = 10
+ay = 20
+bx = 90
+by = 30
+cx = 50
+cy = 80
+#
func sgn px py ax ay bx by .
return sign ((px - bx) * (ay - by) - (ax - bx) * (py - by))
.
@@ -7,10 +14,6 @@ func isin px py ax ay bx by cx cy .
z3 = sgn px py cx cy ax ay
return if abs (z1 + z2 + z3) = 3
.
-ax = 10 ; ay = 20
-bx = 90 ; by = 30
-cx = 50 ; cy = 80
-#
move 5 90
textsize 4
text "Move mouse into the triangle"
diff --git a/Task/Find-the-missing-permutation/FutureBasic/find-the-missing-permutation.basic b/Task/Find-the-missing-permutation/FutureBasic/find-the-missing-permutation.basic
new file mode 100644
index 0000000000..a5bb1361ab
--- /dev/null
+++ b/Task/Find-the-missing-permutation/FutureBasic/find-the-missing-permutation.basic
@@ -0,0 +1,31 @@
+void local fn Permute( string as CFStringRef, result as CFMutableArrayRef, current as CFStringRef )
+ if ( len(string) == 0 ) then MutableArrayAddObject( result, current ) : return
+ for NSUInteger i = 0 to len(string) - 1
+ unichar c = fn StringCharacterAtIndex( string, i )
+ CFMutableStringRef remainingStr = fn MutableStringWithString( string )
+ MutableStringDeleteCharacters( remainingStr, fn RangeMake( i, 1 ) )
+ CFStringRef newCurrent = fn StringByAppendingFormat( current, @"%C", c )
+ fn Permute( remainingStr, result, newCurrent )
+ next
+end fn
+
+local fn DoPermutations as CFStringRef
+ CFStringRef inputString = @"ABCD"
+ CFMutableArrayRef array1 = fn MutableArrayNew
+ fn Permute( inputString, array1, @"" )
+
+ CFArrayRef array2 = @[
+ @"ABCD", @"CABD", @"ACDB", @"DACB", @"BCDA", @"ACBD",
+ @"ADCB", @"CDAB", @"DABC", @"BCAD", @"CADB", @"CDBA",
+ @"CBAD", @"ABDC", @"ADBC", @"BDCA", @"DCBA", @"BACD",
+ @"BADC", @"BDAC", @"CBDA", @"DBCA", @"DCAB"]
+
+ CFMutableSetRef set1 = fn MutableSetWithArray( array1 )
+ CFSetRef set2 = fn SetWithArray( array2 )
+ MutableSetMinusSet( set1, set2 )
+ return fn SetAnyObject( set1 )
+end fn = NULL
+
+printf @"%@", fn DoPermutations
+
+HandleEvents
diff --git a/Task/First-class-functions-Use-numbers-analogously/Java/first-class-functions-use-numbers-analogously.java b/Task/First-class-functions-Use-numbers-analogously/Java/first-class-functions-use-numbers-analogously.java
index 7b381dee6e..69c063ad4d 100644
--- a/Task/First-class-functions-Use-numbers-analogously/Java/first-class-functions-use-numbers-analogously.java
+++ b/Task/First-class-functions-Use-numbers-analogously/Java/first-class-functions-use-numbers-analogously.java
@@ -2,7 +2,7 @@ import java.util.List;
import java.util.function.BiFunction;
import java.util.function.Function;
-public class FirstClassFunctionsUseNumbersAnalogously {
+public final class FirstClassFunctionsUseNumbersAnalogously {
public static void main(String[] args) {
final double x = 2.0, xi = 0.5,
diff --git a/Task/First-class-functions-Use-numbers-analogously/Quackery/first-class-functions-use-numbers-analogously.quackery b/Task/First-class-functions-Use-numbers-analogously/Quackery/first-class-functions-use-numbers-analogously.quackery
new file mode 100644
index 0000000000..e477a97f20
--- /dev/null
+++ b/Task/First-class-functions-Use-numbers-analogously/Quackery/first-class-functions-use-numbers-analogously.quackery
@@ -0,0 +1,14 @@
+ [ $ "bigrat.qky" loadfile ] now!
+
+ [ 2 1 ] is x ( --> n/d )
+ [ 1 2 ] is xi ( --> n/d )
+ [ 4 1 ] is y ( --> n/d )
+ [ 1 4 ] is yi ( --> n/d )
+ [ x y v+ ] is z ( n/d n/d --> n/d )
+ [ x y v+ 1/v ] is zi ( n/d n/d --> n/d )
+
+ [ ' [ v* v* ] join join ] is multiplier ( x n/d --> [ )
+
+' xi ' [ 1 2 ] multiplier dup echo x rot do say " applied to x gives: " vulgar$ echo$ cr
+' yi ' [ 1 2 ] multiplier dup echo y rot do say " applied to y gives: " vulgar$ echo$ cr
+' zi ' [ 1 2 ] multiplier dup echo z rot do say " applied to z gives: " vulgar$ echo$ cr
diff --git a/Task/Fivenum/EMal/fivenum.emal b/Task/Fivenum/EMal/fivenum.emal
index bacb48ca7f..44415e8e61 100644
--- a/Task/Fivenum/EMal/fivenum.emal
+++ b/Task/Fivenum/EMal/fivenum.emal
@@ -2,7 +2,7 @@ type Fivenum
int ILLEGAL_ARGUMENT = 0
fun median = real by List x, int start, int endInclusive
int size = endInclusive - start + 1
- if size <= 0 do Event.error(ILLEGAL_ARGUMENT, "Array slice cannot be empty").raise() end
+ if size <= 0 do error(ILLEGAL_ARGUMENT, "Array slice cannot be empty") end
int m = start + size / 2
return when(size % 2 == 1, x[m], (x[m - 1] + x[m]) / 2.0)
end
diff --git a/Task/Fixed-length-records/Jq/fixed-length-records.jq b/Task/Fixed-length-records/Jq/fixed-length-records.jq
index 8f27c59448..aa773fce7d 100644
--- a/Task/Fixed-length-records/Jq/fixed-length-records.jq
+++ b/Task/Fixed-length-records/Jq/fixed-length-records.jq
@@ -1,4 +1,3 @@
-def cut($n):
def nwise($n):
def n: if length <= $n then . else .[0:$n] , (.[$n:] | n) end;
n;
diff --git a/Task/FizzBuzz/Nu/fizzbuzz-1.nu b/Task/FizzBuzz/Nu/fizzbuzz-1.nu
new file mode 100644
index 0000000000..2ce6276c9d
--- /dev/null
+++ b/Task/FizzBuzz/Nu/fizzbuzz-1.nu
@@ -0,0 +1,9 @@
+1..100 | each {
+ { x: $in, mod3: ($in mod 3), mod5: ($in mod 5), }
+ | match $in {
+ { mod3: 0, mod5: 0, } => 'FizzBuz',
+ { mod3: 0, mod5: _, } => 'Fizz',
+ { mod3: _, mod5: 0, } => 'Buzz',
+ _ => $in.x
+ }
+} | str join "\n"
diff --git a/Task/FizzBuzz/Nu/fizzbuzz-2.nu b/Task/FizzBuzz/Nu/fizzbuzz-2.nu
new file mode 100644
index 0000000000..857bc7cdcb
--- /dev/null
+++ b/Task/FizzBuzz/Nu/fizzbuzz-2.nu
@@ -0,0 +1,3 @@
+1..100 | each {
+ if $in mod 15 == 0 {'FizzBuzz'} else if $in mod 3 == 0 {'Fizz'} else if $in mod 5 == 0 {'Buzz'} else {$in}
+} | str join "\n"
diff --git a/Task/FizzBuzz/Nu/fizzbuzz-3.nu b/Task/FizzBuzz/Nu/fizzbuzz-3.nu
new file mode 100644
index 0000000000..00f958a9c6
--- /dev/null
+++ b/Task/FizzBuzz/Nu/fizzbuzz-3.nu
@@ -0,0 +1,6 @@
+1..100 | each {(
+ if $in mod 15 == 0 {'FizzBuzz'}
+ else if $in mod 3 == 0 {'Fizz'}
+ else if $in mod 5 == 0 {'Buzz'}
+ else {$in}
+)} | str join "\n"
diff --git a/Task/FizzBuzz/Nu/fizzbuzz.nu b/Task/FizzBuzz/Nu/fizzbuzz-4.nu
similarity index 100%
rename from Task/FizzBuzz/Nu/fizzbuzz.nu
rename to Task/FizzBuzz/Nu/fizzbuzz-4.nu
diff --git a/Task/FizzBuzz/Retro/fizzbuzz-1.retro b/Task/FizzBuzz/Retro/fizzbuzz-1.retro
deleted file mode 100644
index beb6d646a4..0000000000
--- a/Task/FizzBuzz/Retro/fizzbuzz-1.retro
+++ /dev/null
@@ -1,8 +0,0 @@
-: fizz? ( s-f ) 3 mod 0 = ;
-: buzz? ( s-f ) 5 mod 0 = ;
-: num? ( s-f ) dup fizz? swap buzz? or 0 = ;
-: ?fizz ( s- ) fizz? [ "Fizz" puts ] ifTrue ;
-: ?buzz ( s- ) buzz? [ "Buzz" puts ] ifTrue ;
-: ?num ( s- ) num? &putn &drop if ;
-: fizzbuzz ( s- ) dup ?fizz dup ?buzz dup ?num space ;
-: all ( - ) 100 [ 1+ fizzbuzz ] iter ;
diff --git a/Task/FizzBuzz/Retro/fizzbuzz-2.retro b/Task/FizzBuzz/Retro/fizzbuzz-2.retro
deleted file mode 100644
index 5912fde82c..0000000000
--- a/Task/FizzBuzz/Retro/fizzbuzz-2.retro
+++ /dev/null
@@ -1,6 +0,0 @@
-needs math'
-: