diff --git a/Conf/lang.yaml b/Conf/lang.yaml index e060b0f2f5..298e845387 100644 --- a/Conf/lang.yaml +++ b/Conf/lang.yaml @@ -16,6 +16,7 @@ A+: .a+ AArch64 Assembly: .aarch64 ABAP: .abap +ABC: .abc ACL2: .acl2 Acornsoft Lisp: .lisp Action!: .action @@ -74,6 +75,8 @@ Asymptote: .asymptote Atari BASIC: .basic ATS: .ats AutoHotkey: .ahk +Autohotkey V2: .ahk +AutoHotKey V2: .ahk AutoIt: .autoit AutoLISP: .l Avail: .avail @@ -209,6 +212,7 @@ DMS: .dms Dodo0: .dodo0 Draco: .draco Dragon: .dragon +DreamBerd: .dreamberd Dt: .dt DUP: .dup DWScript: .dw @@ -292,6 +296,7 @@ F Sharp: .fs FTCBASIC: .basic FunL: .funl Furor: .furor +FurryScript: .furryscript Futhark: .futhark FutureBasic: .basic FUZE BASIC: .basic @@ -311,6 +316,7 @@ GFA Basic: .basic G-fu: .gfu Glagol: .glagol GLBasic: .basic +Gleam: .gleam Glee: .glee Global Script: .global GlovePIE: .glovepie @@ -575,6 +581,7 @@ Oforth: .fth Ol: .ol Omega: .omega Onyx: .onyx +Onyx (wasm): .onyx OOC: .ooc OOCalc: .oocalc OoRexx: .rexx @@ -781,6 +788,7 @@ Star: .star Stata: .stata Stax: .stax StreamIt: .streamit +Stringle: .stringle Suneido: .suneido Superbase BASIC: .basic SuperCollider: .sc @@ -805,6 +813,7 @@ Terraform: .terraform TestML: .tml Thistle: .thistle Thyrd: .thyrd +TI BASIC: .basic TI-57: .ti57 TI-83 BASIC: .basic TI-83 Hex Assembly: .asm diff --git a/Lang/ABC/00-LANG.txt b/Lang/ABC/00-LANG.txt new file mode 100644 index 0000000000..115426b099 --- /dev/null +++ b/Lang/ABC/00-LANG.txt @@ -0,0 +1,18 @@ +{{language +|exec=interpreted +|site=https://homepages.cwi.nl/~steven/abc/ +|strength=strong +|safety=safe +|express=implicit +|checking=dynamic +|parampass=value, reference +|gc=yes}}{{language programming paradigm|Dynamic}}{{language programming paradigm|Imperative}} + +'''ABC''' is a programming language and development environment developed for teaching purposes at the National Research Institute for Mathematics and Computer Science in the Netherlands in the late 80s. It was meant to be a replacement for BASIC in teaching programming to students. The language was meant to be used interactively. Instead of traditional source files, the environment uses workspaces, though the UNIX version does have (rather minimal) script support. Function definitions and global variables persist from session to session without the user having to explicitly save or load them. The environment furthermore includes autocompletion and a syntax-aware editor. There is no supported way to access the underlying OS or file system directly. The tight integration between the language implementation and the IDE turned out to be a barrier to expansion, and the language was largely abandoned in the early 90s. + +There is an unfortunate bug in the official interpreter: it switches to the alternate terminal screen even when running a non-interactive script, resulting in the output being invisible. A workaround is to specify a terminal type that does not support it, e.g. TERM=vt100 abc script.abc. + +==References== + +* [https://homepages.cwi.nl/~steven/abc/ Official homepage] +* [[wp:ABC_(programming_language)|ABC on Wikipedia]] \ No newline at end of file diff --git a/Lang/ABC/00-META.yaml b/Lang/ABC/00-META.yaml new file mode 100644 index 0000000000..967764ae5a --- /dev/null +++ b/Lang/ABC/00-META.yaml @@ -0,0 +1,2 @@ +--- +from: http://rosettacode.org/wiki/Category:ABC diff --git a/Lang/ABC/100-doors b/Lang/ABC/100-doors new file mode 120000 index 0000000000..aa28ef076f --- /dev/null +++ b/Lang/ABC/100-doors @@ -0,0 +1 @@ +../../Task/100-doors/ABC \ No newline at end of file diff --git a/Lang/ABC/100-prisoners b/Lang/ABC/100-prisoners new file mode 120000 index 0000000000..8788c6225a --- /dev/null +++ b/Lang/ABC/100-prisoners @@ -0,0 +1 @@ +../../Task/100-prisoners/ABC \ No newline at end of file diff --git a/Lang/ABC/99-bottles-of-beer b/Lang/ABC/99-bottles-of-beer new file mode 120000 index 0000000000..a68c0a17d5 --- /dev/null +++ b/Lang/ABC/99-bottles-of-beer @@ -0,0 +1 @@ +../../Task/99-bottles-of-beer/ABC \ No newline at end of file diff --git a/Lang/ABC/ABC-problem b/Lang/ABC/ABC-problem new file mode 120000 index 0000000000..925929a8aa --- /dev/null +++ b/Lang/ABC/ABC-problem @@ -0,0 +1 @@ +../../Task/ABC-problem/ABC \ No newline at end of file diff --git a/Lang/ABC/Abundant-deficient-and-perfect-number-classifications b/Lang/ABC/Abundant-deficient-and-perfect-number-classifications new file mode 120000 index 0000000000..7990ee28e5 --- /dev/null +++ b/Lang/ABC/Abundant-deficient-and-perfect-number-classifications @@ -0,0 +1 @@ +../../Task/Abundant-deficient-and-perfect-number-classifications/ABC \ No newline at end of file diff --git a/Lang/ABC/Ackermann-function b/Lang/ABC/Ackermann-function new file mode 120000 index 0000000000..6fc443bd8e --- /dev/null +++ b/Lang/ABC/Ackermann-function @@ -0,0 +1 @@ +../../Task/Ackermann-function/ABC \ No newline at end of file diff --git a/Lang/ABC/Additive-primes b/Lang/ABC/Additive-primes new file mode 120000 index 0000000000..d085a6bcbd --- /dev/null +++ b/Lang/ABC/Additive-primes @@ -0,0 +1 @@ +../../Task/Additive-primes/ABC \ No newline at end of file diff --git a/Lang/ABC/Amicable-pairs b/Lang/ABC/Amicable-pairs new file mode 120000 index 0000000000..144f4590ee --- /dev/null +++ b/Lang/ABC/Amicable-pairs @@ -0,0 +1 @@ +../../Task/Amicable-pairs/ABC \ No newline at end of file diff --git a/Lang/ABC/Attractive-numbers b/Lang/ABC/Attractive-numbers new file mode 120000 index 0000000000..c59a0c88ac --- /dev/null +++ b/Lang/ABC/Attractive-numbers @@ -0,0 +1 @@ +../../Task/Attractive-numbers/ABC \ No newline at end of file diff --git a/Lang/ABC/Benfords-law b/Lang/ABC/Benfords-law new file mode 120000 index 0000000000..f24a94d25a --- /dev/null +++ b/Lang/ABC/Benfords-law @@ -0,0 +1 @@ +../../Task/Benfords-law/ABC \ No newline at end of file diff --git a/Lang/ABC/Bulls-and-cows b/Lang/ABC/Bulls-and-cows new file mode 120000 index 0000000000..fdc423bf64 --- /dev/null +++ b/Lang/ABC/Bulls-and-cows @@ -0,0 +1 @@ +../../Task/Bulls-and-cows/ABC \ No newline at end of file diff --git a/Lang/ABC/Casting-out-nines b/Lang/ABC/Casting-out-nines new file mode 120000 index 0000000000..9c27786e27 --- /dev/null +++ b/Lang/ABC/Casting-out-nines @@ -0,0 +1 @@ +../../Task/Casting-out-nines/ABC \ No newline at end of file diff --git a/Lang/ABC/Comma-quibbling b/Lang/ABC/Comma-quibbling new file mode 120000 index 0000000000..f67b3a793a --- /dev/null +++ b/Lang/ABC/Comma-quibbling @@ -0,0 +1 @@ +../../Task/Comma-quibbling/ABC \ No newline at end of file diff --git a/Lang/ABC/Department-numbers b/Lang/ABC/Department-numbers new file mode 120000 index 0000000000..e903532bc7 --- /dev/null +++ b/Lang/ABC/Department-numbers @@ -0,0 +1 @@ +../../Task/Department-numbers/ABC \ No newline at end of file diff --git a/Lang/ABC/Evolutionary-algorithm b/Lang/ABC/Evolutionary-algorithm new file mode 120000 index 0000000000..d5319b5c74 --- /dev/null +++ b/Lang/ABC/Evolutionary-algorithm @@ -0,0 +1 @@ +../../Task/Evolutionary-algorithm/ABC \ No newline at end of file diff --git a/Lang/ABC/FizzBuzz b/Lang/ABC/FizzBuzz new file mode 120000 index 0000000000..e507dc5bb8 --- /dev/null +++ b/Lang/ABC/FizzBuzz @@ -0,0 +1 @@ +../../Task/FizzBuzz/ABC \ No newline at end of file diff --git a/Lang/ABC/Floyds-triangle b/Lang/ABC/Floyds-triangle new file mode 120000 index 0000000000..b0745131ab --- /dev/null +++ b/Lang/ABC/Floyds-triangle @@ -0,0 +1 @@ +../../Task/Floyds-triangle/ABC \ No newline at end of file diff --git a/Lang/ABC/Giuga-numbers b/Lang/ABC/Giuga-numbers new file mode 120000 index 0000000000..4e8c5ed3a1 --- /dev/null +++ b/Lang/ABC/Giuga-numbers @@ -0,0 +1 @@ +../../Task/Giuga-numbers/ABC \ No newline at end of file diff --git a/Lang/ABC/Hailstone-sequence b/Lang/ABC/Hailstone-sequence new file mode 120000 index 0000000000..22e4b3a8d2 --- /dev/null +++ b/Lang/ABC/Hailstone-sequence @@ -0,0 +1 @@ +../../Task/Hailstone-sequence/ABC \ No newline at end of file diff --git a/Lang/ABC/Happy-numbers b/Lang/ABC/Happy-numbers new file mode 120000 index 0000000000..ffdb78b473 --- /dev/null +++ b/Lang/ABC/Happy-numbers @@ -0,0 +1 @@ +../../Task/Happy-numbers/ABC \ No newline at end of file diff --git a/Lang/ABC/Harshad-or-Niven-series b/Lang/ABC/Harshad-or-Niven-series new file mode 120000 index 0000000000..c460a71d92 --- /dev/null +++ b/Lang/ABC/Harshad-or-Niven-series @@ -0,0 +1 @@ +../../Task/Harshad-or-Niven-series/ABC \ No newline at end of file diff --git a/Lang/ABC/Hofstadter-Figure-Figure-sequences b/Lang/ABC/Hofstadter-Figure-Figure-sequences new file mode 120000 index 0000000000..e400cd4b2d --- /dev/null +++ b/Lang/ABC/Hofstadter-Figure-Figure-sequences @@ -0,0 +1 @@ +../../Task/Hofstadter-Figure-Figure-sequences/ABC \ No newline at end of file diff --git a/Lang/ABC/ISBN13-check-digit b/Lang/ABC/ISBN13-check-digit new file mode 120000 index 0000000000..466684d948 --- /dev/null +++ b/Lang/ABC/ISBN13-check-digit @@ -0,0 +1 @@ +../../Task/ISBN13-check-digit/ABC \ No newline at end of file diff --git a/Lang/ABC/Jewels-and-stones b/Lang/ABC/Jewels-and-stones new file mode 120000 index 0000000000..2a5e2026f3 --- /dev/null +++ b/Lang/ABC/Jewels-and-stones @@ -0,0 +1 @@ +../../Task/Jewels-and-stones/ABC \ No newline at end of file diff --git a/Lang/ABC/Lah-numbers b/Lang/ABC/Lah-numbers new file mode 120000 index 0000000000..264201bfe1 --- /dev/null +++ b/Lang/ABC/Lah-numbers @@ -0,0 +1 @@ +../../Task/Lah-numbers/ABC \ No newline at end of file diff --git a/Lang/ABC/McNuggets-problem b/Lang/ABC/McNuggets-problem new file mode 120000 index 0000000000..95e79a5323 --- /dev/null +++ b/Lang/ABC/McNuggets-problem @@ -0,0 +1 @@ +../../Task/McNuggets-problem/ABC \ No newline at end of file diff --git a/Lang/ABC/Minimum-multiple-of-m-where-digital-sum-equals-m b/Lang/ABC/Minimum-multiple-of-m-where-digital-sum-equals-m new file mode 120000 index 0000000000..6ff647f8c0 --- /dev/null +++ b/Lang/ABC/Minimum-multiple-of-m-where-digital-sum-equals-m @@ -0,0 +1 @@ +../../Task/Minimum-multiple-of-m-where-digital-sum-equals-m/ABC \ No newline at end of file diff --git a/Lang/ABC/Munchausen-numbers b/Lang/ABC/Munchausen-numbers new file mode 120000 index 0000000000..e52466affe --- /dev/null +++ b/Lang/ABC/Munchausen-numbers @@ -0,0 +1 @@ +../../Task/Munchausen-numbers/ABC \ No newline at end of file diff --git a/Lang/ABC/Mutual-recursion b/Lang/ABC/Mutual-recursion new file mode 120000 index 0000000000..7c52c1cb81 --- /dev/null +++ b/Lang/ABC/Mutual-recursion @@ -0,0 +1 @@ +../../Task/Mutual-recursion/ABC \ No newline at end of file diff --git a/Lang/ABC/Primality-by-trial-division b/Lang/ABC/Primality-by-trial-division new file mode 120000 index 0000000000..811bc718a5 --- /dev/null +++ b/Lang/ABC/Primality-by-trial-division @@ -0,0 +1 @@ +../../Task/Primality-by-trial-division/ABC \ No newline at end of file diff --git a/Lang/ABC/Rep-string b/Lang/ABC/Rep-string new file mode 120000 index 0000000000..23f495d764 --- /dev/null +++ b/Lang/ABC/Rep-string @@ -0,0 +1 @@ +../../Task/Rep-string/ABC \ No newline at end of file diff --git a/Lang/ABC/Sequence-of-non-squares b/Lang/ABC/Sequence-of-non-squares new file mode 120000 index 0000000000..0a7560127a --- /dev/null +++ b/Lang/ABC/Sequence-of-non-squares @@ -0,0 +1 @@ +../../Task/Sequence-of-non-squares/ABC \ No newline at end of file diff --git a/Lang/ABC/Sieve-of-Eratosthenes b/Lang/ABC/Sieve-of-Eratosthenes new file mode 120000 index 0000000000..83a8ebdf80 --- /dev/null +++ b/Lang/ABC/Sieve-of-Eratosthenes @@ -0,0 +1 @@ +../../Task/Sieve-of-Eratosthenes/ABC \ No newline at end of file diff --git a/Lang/ABC/Smith-numbers b/Lang/ABC/Smith-numbers new file mode 120000 index 0000000000..ce68a2f99a --- /dev/null +++ b/Lang/ABC/Smith-numbers @@ -0,0 +1 @@ +../../Task/Smith-numbers/ABC \ No newline at end of file diff --git a/Lang/ABC/Strip-a-set-of-characters-from-a-string b/Lang/ABC/Strip-a-set-of-characters-from-a-string new file mode 120000 index 0000000000..c29767f86b --- /dev/null +++ b/Lang/ABC/Strip-a-set-of-characters-from-a-string @@ -0,0 +1 @@ +../../Task/Strip-a-set-of-characters-from-a-string/ABC \ No newline at end of file diff --git a/Lang/ABC/Towers-of-Hanoi b/Lang/ABC/Towers-of-Hanoi new file mode 120000 index 0000000000..37fe93f842 --- /dev/null +++ b/Lang/ABC/Towers-of-Hanoi @@ -0,0 +1 @@ +../../Task/Towers-of-Hanoi/ABC \ No newline at end of file diff --git a/Lang/ABC/Van-Eck-sequence b/Lang/ABC/Van-Eck-sequence new file mode 120000 index 0000000000..6661779e7c --- /dev/null +++ b/Lang/ABC/Van-Eck-sequence @@ -0,0 +1 @@ +../../Task/Van-Eck-sequence/ABC \ 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..a333f928af --- /dev/null +++ b/Lang/AutoHotKey-V2/00-LANG.txt @@ -0,0 +1 @@ +{{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 new file mode 100644 index 0000000000..316ebe0ccb --- /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..89783bc714 --- /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/DreamBerd/00-LANG.txt b/Lang/DreamBerd/00-LANG.txt new file mode 100644 index 0000000000..55321be995 --- /dev/null +++ b/Lang/DreamBerd/00-LANG.txt @@ -0,0 +1,10 @@ +DreamBerd is a perfect esoteric programming language. Some of its features include: +*Array indexes starting at -1 +*No loops +*"Maybe" boolean value +*Many kinds of equality checks +*Type annotations +*"previous/next/current" keywords (for seeing the past/future/present of a variable) +*Signals + +{{language|DreamBerd|exec=interpreted|site=https://github.com/TodePond/DreamBerd|gc=yes}} \ No newline at end of file diff --git a/Lang/DreamBerd/00-META.yaml b/Lang/DreamBerd/00-META.yaml new file mode 100644 index 0000000000..0e5cef5b8d --- /dev/null +++ b/Lang/DreamBerd/00-META.yaml @@ -0,0 +1,2 @@ +--- +from: http://rosettacode.org/wiki/Category:DreamBerd diff --git a/Lang/DreamBerd/Hello-world-Text b/Lang/DreamBerd/Hello-world-Text new file mode 120000 index 0000000000..d474da8442 --- /dev/null +++ b/Lang/DreamBerd/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/DreamBerd \ No newline at end of file diff --git a/Lang/FurryScript/00-LANG.txt b/Lang/FurryScript/00-LANG.txt new file mode 100644 index 0000000000..7daf60d1ef --- /dev/null +++ b/Lang/FurryScript/00-LANG.txt @@ -0,0 +1,12 @@ +{{stub}}{{language|FurryScript|hopl=no}} +From the [https://esolangs.org/wiki/User:Zzo38/FurryScript esolangs.org article]: + +FurryScript is a domain specific programming language (mostly for random text generation), also usable (but not very well) for other programming (as esolangs often are), with some strange features compared with ordinary programming languages: +* The only arithmetic operation is subtraction. +* Negative numbers cannot be entered directly and can only be achieved by subtraction or type casting. +* Strings may contain subroutine calls, but these calls are probabilistic and delayed. +* There are no scalar variables (actually there is one (the input), but it only stores text strings). +* There are only some kinds of loops, and not most of the common kinds found in other programming languages (although it does have some of them). +* List variables and subroutine variables can be anonymous, even though they are not first-class objects. +* There are no conditional blocks. +* Subroutines may exit "OK", "bad", or "very bad", with different effects depending on circumstances. \ No newline at end of file diff --git a/Lang/FurryScript/00-META.yaml b/Lang/FurryScript/00-META.yaml new file mode 100644 index 0000000000..55abe2220c --- /dev/null +++ b/Lang/FurryScript/00-META.yaml @@ -0,0 +1,2 @@ +--- +from: http://rosettacode.org/wiki/Category:FurryScript diff --git a/Lang/FurryScript/Array-length b/Lang/FurryScript/Array-length new file mode 120000 index 0000000000..8ad02a1d07 --- /dev/null +++ b/Lang/FurryScript/Array-length @@ -0,0 +1 @@ +../../Task/Array-length/FurryScript \ No newline at end of file diff --git a/Lang/Gleam/00-LANG.txt b/Lang/Gleam/00-LANG.txt new file mode 100644 index 0000000000..1105755c96 --- /dev/null +++ b/Lang/Gleam/00-LANG.txt @@ -0,0 +1,2 @@ +{{stub}}{{language|Gleam|hopl=no|site=https://gleam.run/}} +Gleam is a type-safe functional programming language that runs on the [[Erlang]] virtual machine. \ No newline at end of file diff --git a/Lang/Gleam/00-META.yaml b/Lang/Gleam/00-META.yaml new file mode 100644 index 0000000000..dd74632ff4 --- /dev/null +++ b/Lang/Gleam/00-META.yaml @@ -0,0 +1,2 @@ +--- +from: http://rosettacode.org/wiki/Category:Gleam diff --git a/Lang/Gleam/FizzBuzz b/Lang/Gleam/FizzBuzz new file mode 120000 index 0000000000..7ce345ddee --- /dev/null +++ b/Lang/Gleam/FizzBuzz @@ -0,0 +1 @@ +../../Task/FizzBuzz/Gleam \ No newline at end of file diff --git a/Lang/Gleam/Hello-world-Text b/Lang/Gleam/Hello-world-Text new file mode 120000 index 0000000000..c444be33a9 --- /dev/null +++ b/Lang/Gleam/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Gleam \ No newline at end of file diff --git a/Lang/Onyx-(wasm)/00-LANG.txt b/Lang/Onyx-(wasm)/00-LANG.txt new file mode 100644 index 0000000000..6a2ea0147f --- /dev/null +++ b/Lang/Onyx-(wasm)/00-LANG.txt @@ -0,0 +1,22 @@ +{{stub}}{{language|site=https://onyxlang.io/}} +Onyx is a WebAssembly-first language (`app.wasm`). WebAssembly can be used inside of a browser but is also growing in popularity outside of the browser, in part due to projects like Wasmer, Wasmtime, and WasmEdge. These "controlled environments" could be game engines, where WASM is used as a "script" system; cloud functions, where WASM is used to respond to requests; plug-in systems for editors or tools. + +Onyx uses a modernized C-like syntax, similar to Jai or Odin. Onyx is an imperative and procedural language in which statements are evaluated in the order they are written in, but does allow for functional-inspired syntax using the pipe operator. + +For example: + + +use core { printf, iter } + +main :: () { + for i in 1 .. 10 { + fact := factorial(i); + printf("{}! = {}\n", i, fact); + } +} + +factorial :: (n: i32) -> i32 { + return iter.as_iter(1 .. n) + |> iter.fold(1, (x, y) => x * y); +} + \ No newline at end of file diff --git a/Lang/Onyx-(wasm)/00-META.yaml b/Lang/Onyx-(wasm)/00-META.yaml new file mode 100644 index 0000000000..cbf74e8a1e --- /dev/null +++ b/Lang/Onyx-(wasm)/00-META.yaml @@ -0,0 +1,2 @@ +--- +from: http://rosettacode.org/wiki/Category:Onyx_(wasm) diff --git a/Lang/Onyx-(wasm)/Almost-prime b/Lang/Onyx-(wasm)/Almost-prime new file mode 120000 index 0000000000..3d86cd989b --- /dev/null +++ b/Lang/Onyx-(wasm)/Almost-prime @@ -0,0 +1 @@ +../../Task/Almost-prime/Onyx-(wasm) \ No newline at end of file diff --git a/Lang/Onyx-(wasm)/Fibonacci-sequence b/Lang/Onyx-(wasm)/Fibonacci-sequence new file mode 120000 index 0000000000..301a591a51 --- /dev/null +++ b/Lang/Onyx-(wasm)/Fibonacci-sequence @@ -0,0 +1 @@ +../../Task/Fibonacci-sequence/Onyx-(wasm) \ No newline at end of file diff --git a/Lang/Onyx-(wasm)/FizzBuzz b/Lang/Onyx-(wasm)/FizzBuzz new file mode 120000 index 0000000000..83ae85030d --- /dev/null +++ b/Lang/Onyx-(wasm)/FizzBuzz @@ -0,0 +1 @@ +../../Task/FizzBuzz/Onyx-(wasm) \ No newline at end of file diff --git a/Lang/Onyx-(wasm)/Golden-ratio-Convergence b/Lang/Onyx-(wasm)/Golden-ratio-Convergence new file mode 120000 index 0000000000..9188efefa7 --- /dev/null +++ b/Lang/Onyx-(wasm)/Golden-ratio-Convergence @@ -0,0 +1 @@ +../../Task/Golden-ratio-Convergence/Onyx-(wasm) \ No newline at end of file diff --git a/Lang/Onyx-(wasm)/Hailstone-sequence b/Lang/Onyx-(wasm)/Hailstone-sequence new file mode 120000 index 0000000000..6121175067 --- /dev/null +++ b/Lang/Onyx-(wasm)/Hailstone-sequence @@ -0,0 +1 @@ +../../Task/Hailstone-sequence/Onyx-(wasm) \ No newline at end of file diff --git a/Lang/Onyx-(wasm)/Hello-world-Text b/Lang/Onyx-(wasm)/Hello-world-Text new file mode 120000 index 0000000000..016c47abd8 --- /dev/null +++ b/Lang/Onyx-(wasm)/Hello-world-Text @@ -0,0 +1 @@ +../../Task/Hello-world-Text/Onyx-(wasm) \ No newline at end of file diff --git a/Lang/Stringle/00-LANG.txt b/Lang/Stringle/00-LANG.txt new file mode 100644 index 0000000000..073e2be961 --- /dev/null +++ b/Lang/Stringle/00-LANG.txt @@ -0,0 +1,28 @@ +{{language|Stringle +|exec=interpreted +|gc=no +|parampass=both +|untyped=yes +}} + +'''Stringle''' is a simple imperative scripting language based around the manipulation of string variables created by Vacek Nules. Its name is a portmanteau of ''string'' and ''wrangle'', being a language to “wrangle strings”. It supports string assignment and concatenation, loops, conditionals with different ''predicates'' and overloaded, composable functions called ''string operators''. + +It has a concise, J-like syntax with single-character operator symbols instead of keywords. Operators are evaluated over strings as functions and are freely composable in arbitrary chains, but some of them can be assigned to as well to modify the string in their argument in various ways. + +[[File:Stringle Cheat Sheet.png|thumb]] + +Stringle has an extremely simple and basic syntax with only a few primitive operators, easily learnt in just a few hours, yet contains highly powerful ways to amplify and combine the building-block operations, like overloaded operators, function pointers and on-demand creation of extensive function chains. + +For a quick example how Stringle looks like, this line of code: + + b %.\c #c #:c + +could be expanded to the following: + + '''if''' b ''contain head reverse'' c '''then set''' ''curtail'' c '''to''' ''length tail'' c + +that is, “delete the last character of c if it occurs in the string b”. + +It is ideal as a replacement for ''sed'' or ''awk'' for creating and running text processing scripts and filters, or could also be used as the built-in macro language in larger applications. + +The complete specification of Stringle can be consulted [https://esolangs.org/wiki/Stringle here]. \ No newline at end of file diff --git a/Lang/Stringle/00-META.yaml b/Lang/Stringle/00-META.yaml new file mode 100644 index 0000000000..2f4df5814d --- /dev/null +++ b/Lang/Stringle/00-META.yaml @@ -0,0 +1,2 @@ +--- +from: http://rosettacode.org/wiki/Category:Stringle diff --git a/Lang/Stringle/100-doors b/Lang/Stringle/100-doors new file mode 120000 index 0000000000..e9007112a9 --- /dev/null +++ b/Lang/Stringle/100-doors @@ -0,0 +1 @@ +../../Task/100-doors/Stringle \ No newline at end of file diff --git a/Lang/Stringle/Nth b/Lang/Stringle/Nth new file mode 120000 index 0000000000..de68672f39 --- /dev/null +++ b/Lang/Stringle/Nth @@ -0,0 +1 @@ +../../Task/Nth/Stringle \ No newline at end of file diff --git a/Lang/Stringle/Reverse-a-string b/Lang/Stringle/Reverse-a-string new file mode 120000 index 0000000000..d32056aac0 --- /dev/null +++ b/Lang/Stringle/Reverse-a-string @@ -0,0 +1 @@ +../../Task/Reverse-a-string/Stringle \ No newline at end of file diff --git a/Lang/Stringle/Rot-13 b/Lang/Stringle/Rot-13 new file mode 120000 index 0000000000..415d6b9707 --- /dev/null +++ b/Lang/Stringle/Rot-13 @@ -0,0 +1 @@ +../../Task/Rot-13/Stringle \ No newline at end of file diff --git a/Lang/Stringle/String-length b/Lang/Stringle/String-length new file mode 120000 index 0000000000..de0a7e0e10 --- /dev/null +++ b/Lang/Stringle/String-length @@ -0,0 +1 @@ +../../Task/String-length/Stringle \ No newline at end of file diff --git a/Lang/Stringle/Strip-a-set-of-characters-from-a-string b/Lang/Stringle/Strip-a-set-of-characters-from-a-string new file mode 120000 index 0000000000..25f1da4301 --- /dev/null +++ b/Lang/Stringle/Strip-a-set-of-characters-from-a-string @@ -0,0 +1 @@ +../../Task/Strip-a-set-of-characters-from-a-string/Stringle \ No newline at end of file diff --git a/Lang/TI-BASIC/00-LANG.txt b/Lang/TI-BASIC/00-LANG.txt new file mode 100644 index 0000000000..05fbe4ee20 --- /dev/null +++ b/Lang/TI-BASIC/00-LANG.txt @@ -0,0 +1,6 @@ +{{stub}}{{language|TI BASIC}} +TI BASIC is the language included in the TI-99/4 (1979) and TI-99/4A (1981) computers. It is similar to Dartmouth BASIC 6th edition. It does not have some features in Microsoft BASIC such as multi-statement lines, other statements after IF..THEN, PEEK, POKE, and USR. It's capabilites are between those of Minimal BASIC and GW-BASIC. It is slower than the BASIC in most other computers but it has high accuracy for calculations. + +It can be used to read and write data files on disk but it is not ideal for reading text files (known as DISPLAY/VARIABLE 80 in the TI file system) because the INPUT #X statement would stop reading a line before the end if it contained a comma. This problem was solved with TI Extended BASIC by the addition of the LINPUT #X statement which is like LINE INPUT# in Microsoft Disk BASIC. + +Many TI-99/4A owners had a TI Extended BASIC cartridge to write or use more advanced programs, including assembly language programs. Almost all TI BASIC programs would run correctly in TI Extended BASIC. \ No newline at end of file diff --git a/Lang/TI-BASIC/00-META.yaml b/Lang/TI-BASIC/00-META.yaml new file mode 100644 index 0000000000..ffd8ce4106 --- /dev/null +++ b/Lang/TI-BASIC/00-META.yaml @@ -0,0 +1,2 @@ +--- +from: http://rosettacode.org/wiki/Category:TI_BASIC diff --git a/Lang/TI-BASIC/Colour-bars-Display b/Lang/TI-BASIC/Colour-bars-Display new file mode 120000 index 0000000000..7be4e2a808 --- /dev/null +++ b/Lang/TI-BASIC/Colour-bars-Display @@ -0,0 +1 @@ +../../Task/Colour-bars-Display/TI-BASIC \ No newline at end of file diff --git a/Task/100-doors/ABC/100-doors.abc b/Task/100-doors/ABC/100-doors.abc new file mode 100644 index 0000000000..59cbdecb64 --- /dev/null +++ b/Task/100-doors/ABC/100-doors.abc @@ -0,0 +1,26 @@ +HOW TO INITIALIZE: + SHARE doors + PUT {} IN doors + FOR door IN {1..100}: + PUT 0 IN doors[door] + +HOW TO TOGGLE door: + SHARE doors + PUT 1-doors[door] IN doors[door] + +HOW TO WALK step: + SHARE doors + PUT step IN door + WHILE door <= 100: + TOGGLE door + PUT door+step IN door + +HOW TO DISPLAY OPEN DOORS: + SHARE doors + FOR door IN {1..100}: + IF doors[door] = 1: + WRITE "Door", door, "is open"/ + +INITIALIZE +FOR pass IN {1..100}: WALK pass +DISPLAY OPEN DOORS diff --git a/Task/100-doors/Stringle/100-doors.stringle b/Task/100-doors/Stringle/100-doors.stringle new file mode 100644 index 0000000000..93035308c5 --- /dev/null +++ b/Task/100-doors/Stringle/100-doors.stringle @@ -0,0 +1,15 @@ +d "." +#d +i d +#i +p "door" #i +*p *p "." +i d f "oc" +i d #@f #*p +i d .\f "o" $ #i +i i d +#i +101 i "" +#i +d d "." +#d +101 d "" +#d diff --git a/Task/100-prisoners/ABC/100-prisoners.abc b/Task/100-prisoners/ABC/100-prisoners.abc new file mode 100644 index 0000000000..0e2c8d9853 --- /dev/null +++ b/Task/100-prisoners/ABC/100-prisoners.abc @@ -0,0 +1,40 @@ +HOW TO FILL drawers: + PUT {} IN drawers + FOR i IN {1..100}: PUT i IN drawers[i] + FOR i IN {1..100}: + PUT choice {i..100} IN j + PUT drawers[i], drawers[j] IN drawers[j], drawers[i] + +HOW TO REPORT prisoner random.strat drawers: + PUT {1..100} IN available + FOR turn IN {1..50}: + PUT choice available IN drawer + IF drawers[drawer] = prisoner: SUCCEED + REMOVE drawer FROM available + FAIL + +HOW TO REPORT prisoner optimal.strat drawers: + PUT prisoner IN drawer + FOR turn IN {1..50}: + IF drawers[drawer] = prisoner: SUCCEED + PUT drawers[drawer] IN drawer + FAIL + +HOW TO REPORT simulate strategy: + FILL drawers + FOR prisoner IN {1..100}: + SELECT: + strategy = "Random": + IF NOT prisoner random.strat drawers: FAIL + strategy = "Optimal": + IF NOT prisoner optimal.strat drawers: FAIL + SUCCEED + +HOW TO RETURN n.sim chance.of.success strategy: + PUT 0 IN success + FOR n IN {1..n.sim}: + IF simulate strategy: PUT success+1 IN success + RETURN success * 100 / n.sim + +FOR strategy IN {"Random"; "Optimal"}: + WRITE strategy, ": ", 10000 chance.of.success strategy, '%'/ diff --git a/Task/99-bottles-of-beer/ABC/99-bottles-of-beer.abc b/Task/99-bottles-of-beer/ABC/99-bottles-of-beer.abc new file mode 100644 index 0000000000..fcc2bcba65 --- /dev/null +++ b/Task/99-bottles-of-beer/ABC/99-bottles-of-beer.abc @@ -0,0 +1,19 @@ +HOW TO RETURN bottles n: + SELECT: + n<0: RETURN "99 bottles" + n=0: RETURN "No more bottles" + n=1: RETURN "1 bottle" + n>1: RETURN "`n` bottles" + +HOW TO SING VERSE n: + WRITE "`bottles n` of beer on the wall,"/ + WRITE "`bottles n` of beer,"/ + SELECT: + n=0: WRITE "Go to the store and buy some more,"/ + n=1: WRITE "Take it down and pass it around,"/ + n>1: WRITE "Take one down and pass it around,"/ + WRITE "`bottles (n-1)` of beer on the wall."/ + WRITE / + +FOR n IN {0..99}: + SING VERSE 99-n diff --git a/Task/ABC-problem/ABC/abc-problem.abc b/Task/ABC-problem/ABC/abc-problem.abc new file mode 100644 index 0000000000..bda16bfbca --- /dev/null +++ b/Task/ABC-problem/ABC/abc-problem.abc @@ -0,0 +1,17 @@ +HOW TO REPORT word can.be.made.with blocks: + FOR letter IN upper word: + IF NO block IN blocks HAS letter in block: FAIL + REMOVE block FROM blocks + SUCCEED + +PUT {"BO";"XK";"DQ";"CP";"NA";"GT";"RE";"TG";"QD";"FS"} IN blocks +PUT {"JW";"HU";"VI";"AN";"OB";"ER";"FS";"LY";"PC";"ZM"} IN blocks2 +FOR block IN blocks2: INSERT block IN blocks + +PUT {"A";"BARK";"BOOK";"treat";"common";"Squad";"CoNfUsE"} IN words + +FOR word IN words: + WRITE word, ": " + SELECT: + word can.be.made.with blocks: WRITE "yes"/ + ELSE: WRITE "no"/ diff --git a/Task/Abundant-deficient-and-perfect-number-classifications/ABC/abundant-deficient-and-perfect-number-classifications.abc b/Task/Abundant-deficient-and-perfect-number-classifications/ABC/abundant-deficient-and-perfect-number-classifications.abc new file mode 100644 index 0000000000..121881f0eb --- /dev/null +++ b/Task/Abundant-deficient-and-perfect-number-classifications/ABC/abundant-deficient-and-perfect-number-classifications.abc @@ -0,0 +1,28 @@ +PUT 0 IN deficient +PUT 0 IN perfect +PUT 0 IN abundant + +HOW TO FIND PROPER DIVISOR SUMS UP TO limit: + SHARE p + PUT {} IN p + FOR i IN {0..limit}: PUT 0 IN p[i] + FOR i IN {1..floor (limit/2)}: + PUT i+i IN j + WHILE j <= limit: + PUT p[j]+i IN p[j] + PUT j+i IN j + +HOW TO CLASSIFY n: + SHARE deficient, perfect, abundant, p + SELECT: + p[n] < n: PUT deficient+1 IN deficient + p[n] = n: PUT perfect+1 IN perfect + p[n] > n: PUT abundant+1 IN abundant + +PUT 20000 IN limit +FIND PROPER DIVISOR SUMS UP TO limit +FOR n IN {1..limit}: CLASSIFY n + +WRITE deficient, "deficient"/ +WRITE perfect, "perfect"/ +WRITE abundant, "abundant"/ diff --git a/Task/Ackermann-function/ABC/ackermann-function.abc b/Task/Ackermann-function/ABC/ackermann-function.abc new file mode 100644 index 0000000000..cbe080f14f --- /dev/null +++ b/Task/Ackermann-function/ABC/ackermann-function.abc @@ -0,0 +1,10 @@ +HOW TO RETURN m ack n: + SELECT: + m=0: RETURN n+1 + m>0 AND n=0: RETURN (m-1) ack 1 + m>0 AND n>0: RETURN (m-1) ack (m ack (n-1)) + +FOR m IN {0..3}: + FOR n IN {0..8}: + WRITE (m ack n)>>6 + WRITE / diff --git a/Task/Additive-primes/ABC/additive-primes.abc b/Task/Additive-primes/ABC/additive-primes.abc new file mode 100644 index 0000000000..27c39a90bf --- /dev/null +++ b/Task/Additive-primes/ABC/additive-primes.abc @@ -0,0 +1,20 @@ +HOW TO REPORT prime n: + REPORT n>=2 AND NO d IN {2..floor root n} HAS n mod d = 0 + +HOW TO RETURN digit.sum n: + SELECT: + n<10: RETURN n + ELSE: RETURN (n mod 10) + digit.sum floor (n/10) + +HOW TO REPORT additive.prime n: + REPORT prime n AND prime digit.sum n + +PUT 0 IN n +FOR i IN {1..499}: + IF additive.prime i: + WRITE i>>4 + PUT n+1 IN n + IF n mod 10 = 0: WRITE / + +WRITE / +WRITE "There are `n` additive primes less than 500."/ diff --git a/Task/Almost-prime/Onyx-(wasm)/almost-prime-1.onyx b/Task/Almost-prime/Onyx-(wasm)/almost-prime-1.onyx new file mode 100644 index 0000000000..38b67acfcb --- /dev/null +++ b/Task/Almost-prime/Onyx-(wasm)/almost-prime-1.onyx @@ -0,0 +1,29 @@ +package main +use core {printf} +main :: () -> void { + printf("\n"); + for k in 1..6 { + printf("k = {}:", k); + i := 2; + c: i32; + while c < 10 { + if kprime(i, k) { + printf(" {}", i); + c += 1; + } + i += 1; + } + printf("\n"); + } +} +kprime :: (n: i32, k: i32) -> bool { + f: i32; + while p := 2; f < k && p * p <= n { + while n % p == 0 { + n /= p; + f += 1; + } + p += 1; + } + return f + (1 if n > 1 else 0) == k; +} diff --git a/Task/Almost-prime/Onyx-(wasm)/almost-prime-2.onyx b/Task/Almost-prime/Onyx-(wasm)/almost-prime-2.onyx new file mode 100644 index 0000000000..0ce967aae2 --- /dev/null +++ b/Task/Almost-prime/Onyx-(wasm)/almost-prime-2.onyx @@ -0,0 +1,37 @@ +//+optional-semicolons +use core {printf} +use core.iter + +main :: () { + generator := + iter.counter(1) + |> iter.map(k => .{ + k = k, kprimes = kprime_iter(k)->take(10) + }) + |> iter.take(5) + + for val in generator { + printf("k = {}:", val.k) + for p in val.kprimes do printf(" {}", p) + printf("\n") + } +} + +kprime_iter :: k => + iter.counter(2) + |> iter.filter((i, [k]) => kprime(i, k)) + +kprime :: (n, k) => { + f := 0 + for p in iter.counter(2) { + if f >= k do break + if p * p > n do break + + while n % p == 0 { + n /= p + f += 1 + } + } + + return f + (1 if n > 1 else 0) == k +} diff --git a/Task/Amicable-pairs/ABC/amicable-pairs.abc b/Task/Amicable-pairs/ABC/amicable-pairs.abc new file mode 100644 index 0000000000..b0b5e61740 --- /dev/null +++ b/Task/Amicable-pairs/ABC/amicable-pairs.abc @@ -0,0 +1,17 @@ +HOW TO RETURN proper.divisor.sum.table n: + PUT {} IN propdivs + FOR i IN {1..n}: PUT 1 IN propdivs[i] + FOR i IN {2..floor (n/2)}: + PUT i+i IN j + WHILE j<=n: + PUT propdivs[j] + i IN propdivs[j] + PUT i + j IN j + RETURN propdivs + +PUT 20000 IN maximum +PUT proper.divisor.sum.table maximum IN propdivs + +FOR cand IN {1..maximum}: + PUT propdivs[cand] IN other + IF cand ) +COUNT[ 0 SW ~| COUNT_STEP# 0 SW SU ] +COUNT_STEP[ DR 1 SU ] + +`THE_LIST COUNT# +<> diff --git a/Task/Attractive-numbers/ABC/attractive-numbers.abc b/Task/Attractive-numbers/ABC/attractive-numbers.abc new file mode 100644 index 0000000000..39deb4a838 --- /dev/null +++ b/Task/Attractive-numbers/ABC/attractive-numbers.abc @@ -0,0 +1,21 @@ +HOW TO RETURN factors n: + PUT {} IN factors + PUT 2 IN factor + WHILE n >= factor: + SELECT: + n mod factor = 0: + INSERT factor IN factors + PUT n/factor IN n + ELSE: + PUT factor+1 IN factor + RETURN factors + +HOW TO REPORT attractive n: + REPORT 1 = #factors #factors n + +PUT 0 IN col +FOR i IN {1..120}: + IF attractive i: + WRITE i>>5 + PUT col+1 IN col + IF col mod 10=0: WRITE / diff --git a/Task/Benfords-law/ABC/benfords-law.abc b/Task/Benfords-law/ABC/benfords-law.abc new file mode 100644 index 0000000000..7d3f54fa55 --- /dev/null +++ b/Task/Benfords-law/ABC/benfords-law.abc @@ -0,0 +1,25 @@ +HOW TO RETURN fibonacci.numbers n: + PUT 1, 1 IN a, b + PUT {} IN fibo + FOR i IN {1..n}: + INSERT a IN fibo + PUT b, a+b IN a, b + RETURN fibo + +HOW TO RETURN digit.distribution nums: + PUT {} IN digits + FOR i IN {1..9}: PUT i IN digits["`i`"] + PUT {} IN dist + FOR i IN {1..9}: PUT 0 IN dist[i] + FOR n IN nums: + PUT digits["`n`"|1] IN digit + PUT dist[digit] + 1 IN dist[digit] + FOR i IN {1..9}: + PUT dist[i] / #nums IN dist[i] + RETURN dist + +PUT digit.distribution fibonacci.numbers 1000 IN observations + +WRITE "Digit"<<6, "Expected">>10, "Observed">>10/ +FOR d IN {1..9}: + WRITE d<<6, ((10 log (1 + 1/d))>>10)|10, observations[d]>>10/ diff --git a/Task/Bulls-and-cows/ABC/bulls-and-cows.abc b/Task/Bulls-and-cows/ABC/bulls-and-cows.abc new file mode 100644 index 0000000000..06f156193a --- /dev/null +++ b/Task/Bulls-and-cows/ABC/bulls-and-cows.abc @@ -0,0 +1,62 @@ +HOW TO RETURN random.digit: + RETURN choice "123456789" + +HOW TO MAKE SECRET secret: + PUT "" IN secret + FOR i IN {1..4}: + PUT random.digit IN digit + WHILE SOME j IN {1..i-1} HAS secret item j = digit: + PUT random.digit IN digit + PUT secret^digit IN secret + +HOW TO RETURN guess count.bulls secret: + PUT 0 IN bulls + FOR i IN {1..4}: + IF secret item i = guess item i: PUT bulls+1 IN bulls + RETURN bulls + +HOW TO RETURN guess count.cows secret: + PUT -(guess count.bulls secret) IN cows + FOR c IN guess: + IF c in secret: PUT cows+1 IN cows + RETURN cows + +HOW TO REPORT has.duplicates guess: + FOR i IN {1..3}: + FOR j IN {i+1..4}: + IF guess item i = guess item j: SUCCEED + FAIL + +HOW TO REPORT is.valid guess: + IF SOME digit IN guess HAS digit not.in "123456789": + WRITE "Invalid digit: ", digit/ + FAIL + IF #guess <> 4: + WRITE "Guess must contain 4 digits."/ + FAIL + IF has.duplicates guess: + WRITE "No duplicates allowed"/ + FAIL + SUCCEED + +HOW TO READ GUESS guess: + WHILE 1=1: + WRITE "Guess? " + READ guess RAW + IF is.valid guess: QUIT + +HOW TO PLAY BULLS AND COWS: + PUT 0, 0, 0 IN tries, bulls, cows + MAKE SECRET secret + WRITE "Bulls and cows"/ + WRITE "--------------"/ + WRITE / + WHILE bulls<>4: + READ GUESS guess + PUT guess count.bulls secret IN bulls + PUT guess count.cows secret IN cows + WRITE "Bulls:",bulls,"- Cows:",cows/ + PUT tries+1 IN tries + WRITE "You win! Tries:", tries + +PLAY BULLS AND COWS diff --git a/Task/Casting-out-nines/ABC/casting-out-nines.abc b/Task/Casting-out-nines/ABC/casting-out-nines.abc new file mode 100644 index 0000000000..72dd29d4b4 --- /dev/null +++ b/Task/Casting-out-nines/ABC/casting-out-nines.abc @@ -0,0 +1,12 @@ +\ casting out nines - based on the Action! sample + +HOW TO ADD v TO n: PUT n + v IN n + +PUT 10, 2, 0, 0 IN base, n, count, total +FOR i IN { 1 .. base ** n }: + ADD 1 TO total + IF i mod ( base - 1 ) = ( i * i ) mod ( base - 1 ): + ADD 1 TO count + WRITE i +WRITE // "Trying", count, "numbers instead of", total, "numbers saves" +WRITE 100 - ( ( 100 * count ) / total ), "%" / diff --git a/Task/Colour-bars-Display/TI-BASIC/colour-bars-display.basic b/Task/Colour-bars-Display/TI-BASIC/colour-bars-display.basic new file mode 100644 index 0000000000..5446b20b38 --- /dev/null +++ b/Task/Colour-bars-Display/TI-BASIC/colour-bars-display.basic @@ -0,0 +1,43 @@ +100 REM SMPTE Format Color Bars +110 REM with 400 Hz reference tone +120 CALL CLEAR +130 CALL SCREEN(2) +140 CALL COLOR(8,15,1) +150 CALL COLOR(9,11,1) +160 CALL COLOR(10,8,1) +170 CALL COLOR(11,13,1) +180 CALL COLOR(12,14,1) +190 CALL COLOR(13,10,1) +200 CALL COLOR(14,5,1) +210 CALL COLOR(15,2,1) +220 CALL COLOR(16,16,1) +230 GOSUB 510 +240 REM color bars +250 CALL VCHAR(1,3,88,96) +260 CALL VCHAR(1,7,96,96) +270 CALL VCHAR(1,11,104,96) +280 CALL VCHAR(1,15,112,96) +290 CALL VCHAR(1,19,120,96) +300 CALL VCHAR(1,23,128,96) +310 CALL VCHAR(1,27,136,96) +320 REM BLACK BAR +330 CALL HCHAR(19,1,144,224) +340 REM WHITE BOX +350 FOR I=19 TO 24 +360 CALL HCHAR(I,8,152,6) +370 NEXT I +410 REM SMPTE Complementary boxes +420 CALL HCHAR(18,3,136,4) +430 CALL HCHAR(18,7,144,4) +440 CALL HCHAR(18,11,120,4) +450 CALL HCHAR(18,15,144,4) +460 CALL HCHAR(18,19,104,4) +470 CALL HCHAR(18,23,144,4) +480 CALL HCHAR(18,27,88,4) +490 CALL SOUND(3000,400,12) +500 GOTO 490 +510 SQUARE$="FFFFFFFFFFFFFFFF" +520 FOR I = 88 TO 152 STEP 8 +530 CALL CHAR(I,SQUARE$) +540 NEXT I +590 RETURN diff --git a/Task/Comma-quibbling/ABC/comma-quibbling.abc b/Task/Comma-quibbling/ABC/comma-quibbling.abc new file mode 100644 index 0000000000..42fb869f67 --- /dev/null +++ b/Task/Comma-quibbling/ABC/comma-quibbling.abc @@ -0,0 +1,17 @@ +HOW TO RETURN quibble words: + PUT "" IN result + PUT #words IN remaining + FOR word IN words: + PUT result^word IN result + PUT remaining-1 IN remaining + IF remaining = 1: PUT result^" and " IN result + IF remaining > 1: PUT result^", " IN result + RETURN "{" ^ result ^ "}" + +PUT {} IN tests +INSERT {} IN tests +INSERT {[1]: "ABC"} IN tests +INSERT {[1]: "ABC"; [2]: "DEF"} IN tests +INSERT {[1]: "ABC"; [2]: "DEF"; [3]: "G"; [4]: "H"} IN tests +FOR test IN tests: + WRITE quibble test/ diff --git a/Task/Department-numbers/ABC/department-numbers.abc b/Task/Department-numbers/ABC/department-numbers.abc new file mode 100644 index 0000000000..a64e96d6d8 --- /dev/null +++ b/Task/Department-numbers/ABC/department-numbers.abc @@ -0,0 +1,11 @@ +PUT 7 IN max.department.number +PUT 12 IN department.sum +WRITE "police sanitation fire" / +PUT 2 IN police +WHILE police <= max.department.number: + FOR sanitation IN { 1 .. max.department.number }: + IF sanitation <> police: + PUT ( department.sum - police ) - sanitation IN fire + IF fire > 0 AND fire <= max.department.number AND fire <> sanitation AND fire <> police: + WRITE police>>6, sanitation>>11, fire>>5 / + PUT police + 2 IN police diff --git a/Task/Evolutionary-algorithm/ABC/evolutionary-algorithm.abc b/Task/Evolutionary-algorithm/ABC/evolutionary-algorithm.abc new file mode 100644 index 0000000000..8b34ace597 --- /dev/null +++ b/Task/Evolutionary-algorithm/ABC/evolutionary-algorithm.abc @@ -0,0 +1,39 @@ +PUT "ABCDEFGHIJKLMNOPQRSTUVWXYZ " IN alphabet + +HOW TO RETURN initial.state target: + SHARE alphabet + PUT "" IN state + FOR c IN target: PUT state^choice alphabet IN state + RETURN state + +HOW TO RETURN state fitness target: + PUT #target IN score + FOR i IN {1..#target}: + IF state item i = target item i: PUT score-1 IN score + RETURN score + +HOW TO RETURN chance mutate state: + SHARE alphabet + PUT "" IN mutated + FOR i IN {1..#state}: + SELECT: + random < chance: PUT choice alphabet IN next + ELSE: PUT state item i IN next + PUT mutated^next IN mutated + RETURN mutated + +HOW TO EVOLVE TOWARD target: + PUT 0.1 IN mutation.rate + PUT 100 IN generation.size + PUT initial.state target IN state + WHILE state fitness target > 0: + WRITE (state fitness target)>>2, ": ", state/ + PUT {} IN next.generation + FOR i IN {1..generation.size}: + PUT mutation.rate mutate state IN child + PUT child fitness target IN score + PUT child IN next.generation[score] + PUT next.generation[min keys next.generation] IN state + WRITE (state fitness target)>>2, ": ", state/ + +EVOLVE TOWARD "METHINKS IT IS LIKE A WEASEL" diff --git a/Task/Fibonacci-sequence/Onyx-(wasm)/fibonacci-sequence.onyx b/Task/Fibonacci-sequence/Onyx-(wasm)/fibonacci-sequence.onyx new file mode 100644 index 0000000000..64534f6e36 --- /dev/null +++ b/Task/Fibonacci-sequence/Onyx-(wasm)/fibonacci-sequence.onyx @@ -0,0 +1,64 @@ +use core.iter +use core { printf } + +// Procedural Simple For-Loop Style +fib_for_loop :: (n: i32) -> i32 { + a: i32 = 0; + b: i32 = 1; + for 0 .. n { + tmp := a; + a = b; + b = tmp + b; + } + return a; +} + +FibState :: struct { a, b: u64 } + +// Functional Folding Style +fib_by_fold :: (n: i32) => { + end_state := + iter.counter() + |> iter.take(n) + |> iter.fold( + FibState.{ a = 0, b = 1 }, + (_, state) => FibState.{ + a = state.b, + b = state.a + state.b + } + ); + return end_state.a; +} + +// Custom Iterator Style +fib_iterator :: (n: i32) => + iter.generator( + &.{ a = cast(u64) 0, b = cast(u64) 1, counter = n }, + (state: & $Ctx) -> (u64, bool) { + if state.counter <= 0 { + return 0, false; + } + tmp := state.a; + state.a = state.b; + state.b = state.b + tmp; + state.counter -= 1; + return tmp, true; + } + ); + +main :: () { + printf("\nBy For Loop:\n"); + for i in 0 .. 21 { + printf("{} ", fib_for_loop(i)); + } + + printf("\n\nBy Iterator:\n"); + for i in 0 .. 21 { + printf("{} ", fib_by_fold(i)); + } + + printf("\n\nBy Fold:\n"); + for value, index in fib_iterator(21) { + printf("{} ", value); + } +} diff --git a/Task/FizzBuzz/ABC/fizzbuzz.abc b/Task/FizzBuzz/ABC/fizzbuzz.abc new file mode 100644 index 0000000000..4f46c4f26e --- /dev/null +++ b/Task/FizzBuzz/ABC/fizzbuzz.abc @@ -0,0 +1,12 @@ +HOW TO RETURN fizzbuzz num: + PUT "" IN result + PUT {[3]: "Fizz"; [5]: "Buzz"} IN divwords + FOR div IN keys divwords: + IF num mod div=0: + PUT result^divwords[div] IN result + IF result="": + PUT num>>0 IN result + RETURN result + +FOR i IN {1..100}: + WRITE fizzbuzz i/ diff --git a/Task/FizzBuzz/Gleam/fizzbuzz.gleam b/Task/FizzBuzz/Gleam/fizzbuzz.gleam new file mode 100644 index 0000000000..3144c3e6e8 --- /dev/null +++ b/Task/FizzBuzz/Gleam/fizzbuzz.gleam @@ -0,0 +1,19 @@ +import gleam/int +import gleam/io +import gleam/iterator + +pub fn main() { + iterator.range(1, 101) + |> iterator.map(to_fizzbuzz) + |> iterator.map(io.println) + |> iterator.run +} + +fn to_fizzbuzz(n: Int) -> String { + case n % 3, n % 5 { + 0, 0 -> "FizzBuzz" + 0, _ -> "Fizz" + _, 0 -> "Buzz" + _, _ -> int.to_string(n) + } +} diff --git a/Task/FizzBuzz/Onyx-(wasm)/fizzbuzz.onyx b/Task/FizzBuzz/Onyx-(wasm)/fizzbuzz.onyx new file mode 100644 index 0000000000..9eac032733 --- /dev/null +++ b/Task/FizzBuzz/Onyx-(wasm)/fizzbuzz.onyx @@ -0,0 +1,16 @@ +use core { * } + +fizzbuzz :: (len: u32) -> void { + for i in 1..len+1 { + msg : str; + if (i%3 == 0 && i%5 == 0) { msg = "FizzBuzz !!!"; } + elseif (i%3 == 0) { msg = "Fizz"; } + elseif (i%5 == 0) { msg = "Buzz"; } + else { msg = tprintf("{}", i); } + printf("{}\n", msg); + } +} + +main :: () { + fizzbuzz(100); +} diff --git a/Task/Floyds-triangle/ABC/floyds-triangle.abc b/Task/Floyds-triangle/ABC/floyds-triangle.abc new file mode 100644 index 0000000000..8d18d171cf --- /dev/null +++ b/Task/Floyds-triangle/ABC/floyds-triangle.abc @@ -0,0 +1,18 @@ +HOW TO RETURN width n: + SELECT: + n<10: RETURN 1 + ELSE: RETURN 1 + width floor (n/10) + +HOW TO DISPLAY A FLOYD TRIANGLE WITH lines LINES: + PUT lines * (lines+1)/2 IN maxno + PUT 1 IN n + FOR line IN {1..lines}: + FOR col IN {1..line}: + WRITE n >> (1 + width (maxno - lines + col)) + PUT n+1 IN n + WRITE / + +DISPLAY A FLOYD TRIANGLE WITH 5 LINES +WRITE / +DISPLAY A FLOYD TRIANGLE WITH 14 LINES +WRITE / diff --git a/Task/Giuga-numbers/ABC/giuga-numbers.abc b/Task/Giuga-numbers/ABC/giuga-numbers.abc new file mode 100644 index 0000000000..2d63aba191 --- /dev/null +++ b/Task/Giuga-numbers/ABC/giuga-numbers.abc @@ -0,0 +1,21 @@ +HOW TO REPORT is.giuga n: + \ each prime factor must appear only once, e.g.: for 2: + \ [ ( n / 2 ) - 1 ] mod 2 = 0 => n / 2 is odd => n isn't divisible by 4 + \ similarly for other primes + PUT 1, 3, 1, floor( n / 2 ) IN f.count, f, giuga, v + WHILE f <= v AND giuga = 1: + IF v mod f = 0: + PUT f.count + 1 IN f.count + IF ( ( floor( n / f ) ) - 1 ) mod f <> 0: PUT 0 IN giuga + PUT floor( v / f ) IN v + PUT f + 2 IN f + IF giuga = 1: \ n is still a candidate, check it is not prime + IF f.count = 1: FAIL \ only 1 factor - it is prime so not giuga + REPORT giuga = 1 + +PUT 0, -2 IN g.count, n +WHILE g.count < 4: + PUT n + 4 IN n \ assume the numbers are all even + IF is.giuga n: + PUT g.count + 1 IN g.count + WRITE n diff --git a/Task/Golden-ratio-Convergence/Onyx-(wasm)/golden-ratio-convergence.onyx b/Task/Golden-ratio-Convergence/Onyx-(wasm)/golden-ratio-convergence.onyx new file mode 100644 index 0000000000..81df1f1637 --- /dev/null +++ b/Task/Golden-ratio-Convergence/Onyx-(wasm)/golden-ratio-convergence.onyx @@ -0,0 +1,26 @@ +package main +use core {*} +use core.math{abs} +use core.intrinsics.wasm{sqrt_f64} +main :: () { + iterate(); +} +iterate :: () { + count := 0; + phi0: f64 = 1.0; + difference: f64 = 1.0; + phi1: f64; + println("\nGolden ratio/Convergence"); + println("-----------------------------------------"); + while 0.00001 < difference { + phi1 = 1.0 + (1.0 / phi0); + difference = abs(phi1 - phi0); + phi0 = phi1; + count += 1; + printf("Iteration {} : Estimate : {.8}\n", count, phi1); + } + println("-----------------------------------------"); + printf("Result: {} after {} iterations", phi1, count); + printf("\nThe error is approximately {.8}\n", (phi1 - (0.5 * (1.0 + sqrt_f64(5.0))))); + println("\n"); +} diff --git a/Task/Hailstone-sequence/ABC/hailstone-sequence.abc b/Task/Hailstone-sequence/ABC/hailstone-sequence.abc new file mode 100644 index 0000000000..7241e86e8f --- /dev/null +++ b/Task/Hailstone-sequence/ABC/hailstone-sequence.abc @@ -0,0 +1,22 @@ +HOW TO RETURN hailstone n: + PUT {} IN seq + WHILE 1=1: + PUT n IN seq[#seq] + SELECT: + n=1: RETURN seq + n mod 2=0: PUT floor(n/2) IN n + n mod 2=1: PUT 3*n+1 IN n + RETURN seq + +PUT hailstone 27 IN h27 +WRITE "Length of Hailstone sequence for 27:", #h27/ +WRITE "First 4 elements:", h27[0], h27[1], h27[2], h27[3]/ +WRITE "Last 4 elements:", h27[#h27-4], h27[#h27-3], h27[#h27-2], h27[#h27-1]/ + +PUT 0, 0 IN longest, length +FOR n IN {1..100000}: + PUT hailstone n IN hn + IF #hn > length: + PUT n, #hn IN longest, length + +WRITE longest, "has the longest hailstone sequence < 100,000, of length:", length/ diff --git a/Task/Hailstone-sequence/Onyx-(wasm)/hailstone-sequence.onyx b/Task/Hailstone-sequence/Onyx-(wasm)/hailstone-sequence.onyx new file mode 100644 index 0000000000..db662f03ce --- /dev/null +++ b/Task/Hailstone-sequence/Onyx-(wasm)/hailstone-sequence.onyx @@ -0,0 +1,61 @@ +use core { * } + +hailstone :: (n: u32) -> [..]u32 { + seq: [..]u32; + array.push(&seq, n); + while n > 1 { + n = n/2 if n%2 == 0 else (n*3)+1; + array.push(&seq, n); + } + return seq; +} + +Longest :: struct { num, len : u32; } + +main :: () { + + // ------- + // task 1: + // ------- + // "Create a routine to generate the hailstone + // sequence for a number." + + i := 27; + seq := hailstone(i); + printf("Task 1:\n{}: {}\n\n", + i, + seq + ); + + // ------- + // task 2: + // ------- + // "Use the routine to show that the hailstone + // sequence for the number 27 has + // 112 elements starting with + // 27, 82, 41, 124 and ending with 8, 4, 2, 1" + + slice_size := 4; + len := seq.length; + slice_first := seq[0..slice_size]; + slice_last := seq[seq.length-slice_size..seq.length]; + printf("Task 2:\nlength: {}, first: {}, last: {}\n\n", + len, + slice_first, + slice_last + ); + + // ------- + // task 3: + // ------- + // "Show the number less than 100,000 + // which has the longest hailstone sequence + // together with that sequences length." + + l : Longest; + for i in 1..100000 { + seq := hailstone(i); + if l.len < seq.length { l = .{num = i, len = seq.length}; } + } + printf("Task 3:\nLongest Num: {}, Sequence Length: {}\n", l.num, l.len); +} diff --git a/Task/Happy-numbers/ABC/happy-numbers.abc b/Task/Happy-numbers/ABC/happy-numbers.abc new file mode 100644 index 0000000000..befec4774e --- /dev/null +++ b/Task/Happy-numbers/ABC/happy-numbers.abc @@ -0,0 +1,24 @@ +HOW TO RETURN square.digit.sum n: + PUT 0 IN sum + WHILE n>0: + PUT n mod 10 IN digit + PUT sum + digit ** 2 IN sum + PUT floor (n/10) IN n + RETURN sum + +HOW TO REPORT happy n: + PUT {} IN seen + WHILE n not.in seen: + INSERT n IN seen + PUT square.digit.sum n IN n + REPORT n=1 + +HOW TO RETURN next.happy n: + PUT n+1 IN n + WHILE NOT happy n: PUT n+1 IN n + RETURN n + +PUT 0 IN n +FOR i IN {1..8}: + PUT next.happy n IN n + WRITE n/ diff --git a/Task/Harshad-or-Niven-series/ABC/harshad-or-niven-series.abc b/Task/Harshad-or-Niven-series/ABC/harshad-or-niven-series.abc new file mode 100644 index 0000000000..936b17dfd8 --- /dev/null +++ b/Task/Harshad-or-Niven-series/ABC/harshad-or-niven-series.abc @@ -0,0 +1,22 @@ +HOW TO RETURN digit.sum n: + PUT 0 IN sum + WHILE n>0: + PUT sum + (n mod 10) IN sum + PUT floor (n/10) IN n + RETURN sum + +HOW TO REPORT harshad n: + REPORT n mod digit.sum n = 0 + +HOW TO RETURN next.harshad n: + PUT n+1 IN n + WHILE NOT harshad n: PUT n+1 IN n + RETURN n + +PUT 0 IN n +WRITE "First 20 Harshad numbers:" +FOR i IN {1..20}: + PUT next.harshad n IN n + WRITE n +WRITE / +WRITE "First Harshad number > 1000:", next.harshad 1000/ diff --git a/Task/Hello-world-Graphical/AutoHotKey-V2/hello-world-graphical.ahk b/Task/Hello-world-Graphical/AutoHotKey-V2/hello-world-graphical.ahk new file mode 100644 index 0000000000..10aac5feb8 --- /dev/null +++ b/Task/Hello-world-Graphical/AutoHotKey-V2/hello-world-graphical.ahk @@ -0,0 +1 @@ +MsgBox("Goodbye, World!") diff --git a/Task/Hello-world-Text/DreamBerd/hello-world-text.dreamberd b/Task/Hello-world-Text/DreamBerd/hello-world-text.dreamberd new file mode 100644 index 0000000000..3caff2b5fa --- /dev/null +++ b/Task/Hello-world-Text/DreamBerd/hello-world-text.dreamberd @@ -0,0 +1 @@ +print "Hello world!"! diff --git a/Task/Hello-world-Text/Gleam/hello-world-text.gleam b/Task/Hello-world-Text/Gleam/hello-world-text.gleam new file mode 100644 index 0000000000..a247748d26 --- /dev/null +++ b/Task/Hello-world-Text/Gleam/hello-world-text.gleam @@ -0,0 +1,5 @@ +import gleam/io + +pub fn main() { + io.println("Hello world!") +} diff --git a/Task/Hello-world-Text/Onyx-(wasm)/hello-world-text.onyx b/Task/Hello-world-Text/Onyx-(wasm)/hello-world-text.onyx new file mode 100644 index 0000000000..f2eebbdd12 --- /dev/null +++ b/Task/Hello-world-Text/Onyx-(wasm)/hello-world-text.onyx @@ -0,0 +1,4 @@ +use core {printf} +main :: () { + printf("Hello world!"); +} diff --git a/Task/Hofstadter-Figure-Figure-sequences/ABC/hofstadter-figure-figure-sequences.abc b/Task/Hofstadter-Figure-Figure-sequences/ABC/hofstadter-figure-figure-sequences.abc new file mode 100644 index 0000000000..e4909efcd1 --- /dev/null +++ b/Task/Hofstadter-Figure-Figure-sequences/ABC/hofstadter-figure-figure-sequences.abc @@ -0,0 +1,35 @@ +PUT {[1]: 1} IN r.list +PUT {[1]: 2} IN s.list + +HOW TO EXTEND R TO n: + SHARE r.list, s.list + WHILE n > #r.list: + PUT r.list[#r.list] + s.list[#r.list] IN next.r + FOR i IN {s.list[#s.list]+1 .. next.r-1}: + PUT i IN s.list[#s.list+1] + PUT next.r IN r.list[#r.list+1] + PUT next.r + 1 IN s.list[#s.list+1] + +HOW TO EXTEND S TO n: + SHARE r.list, s.list + WHILE n > #s.list: EXTEND R TO #r.list + 1 + +HOW TO RETURN ffr n: + SHARE r.list + IF n > #r.list: EXTEND R TO n + RETURN r.list[n] + +HOW TO RETURN ffs n: + SHARE s.list + IF n > #s.list: EXTEND S TO n + RETURN s.list[n] + +WRITE "R[1..10]:" +FOR i IN {1..10}: WRITE ffr i +WRITE / + +PUT {} IN thousand +FOR i IN {1..40}: INSERT ffr i IN thousand +FOR i IN {1..960}: INSERT ffs i IN thousand +IF thousand = {1..1000}: + WRITE "R[1..40] + S[1..960] = [1..1000]"/ diff --git a/Task/ISBN13-check-digit/ABC/isbn13-check-digit.abc b/Task/ISBN13-check-digit/ABC/isbn13-check-digit.abc new file mode 100644 index 0000000000..1129049657 --- /dev/null +++ b/Task/ISBN13-check-digit/ABC/isbn13-check-digit.abc @@ -0,0 +1,21 @@ +HOW TO REPORT valid.isbn13 str: + PUT {} IN digits + FOR d IN {0..9}: PUT d IN digits["`d`"] + IF #str <> 14 OR str item 4 <> '-': FAIL + PUT 1, 0 IN mul, sum + FOR c IN str|3 ^ str@5: + IF c not.in keys digits: FAIL + PUT sum + digits[c] * mul IN sum + PUT 4 - mul IN mul + REPORT sum mod 10 = 0 + +PUT {} IN tests +PUT "978-0596528126" IN tests[1] +PUT "978-0596528120" IN tests[2] +PUT "978-1788399081" IN tests[3] +PUT "978-1788399083" IN tests[4] + +FOR test IN tests: + SELECT: + valid.isbn13 test: WRITE test^": good"/ + ELSE: WRITE test^": bad"/ diff --git a/Task/Jewels-and-stones/ABC/jewels-and-stones.abc b/Task/Jewels-and-stones/ABC/jewels-and-stones.abc new file mode 100644 index 0000000000..63a5a6a93e --- /dev/null +++ b/Task/Jewels-and-stones/ABC/jewels-and-stones.abc @@ -0,0 +1,8 @@ +HOW TO RETURN stones count.in jewels: + PUT 0 IN count + FOR stone IN stones: + IF stone in jewels: PUT count+1 IN count + RETURN count + +WRITE "aAAbbbb" count.in "aA"/ +WRITE "ZZ" count.in "z"/ diff --git a/Task/Lah-numbers/ABC/lah-numbers.abc b/Task/Lah-numbers/ABC/lah-numbers.abc new file mode 100644 index 0000000000..9526a25e96 --- /dev/null +++ b/Task/Lah-numbers/ABC/lah-numbers.abc @@ -0,0 +1,30 @@ +HOW TO RETURN fac n: + PUT 1 IN result + FOR i IN {1..n}: PUT result*i IN result + RETURN result + +HOW TO RETURN n lah k: + SELECT: + n=k: RETURN 1 + n=0 OR k=0: RETURN 0 + k=1: RETURN fac n + ELSE: RETURN (((fac n)*fac(n-1)) / ((fac k)*fac(k-1)) )/ fac(n-k) + +HOW TO SHOW LAH TABLE UP TO N nmax: + FOR n IN {0..nmax}: + FOR k IN {0..n}: + WRITE (n lah k)>>11 + WRITE / + +HOW TO RETURN max.lah.number n: + PUT 0 IN max + FOR k IN {0..n}: + PUT n lah k IN cur + IF cur>max: PUT cur IN max + RETURN max + + +SHOW LAH TABLE UP TO N 12 +WRITE / +WRITE "Maximum value where n=100:"/ +WRITE max.lah.number 100/ diff --git a/Task/McNuggets-problem/ABC/mcnuggets-problem.abc b/Task/McNuggets-problem/ABC/mcnuggets-problem.abc new file mode 100644 index 0000000000..a28520502e --- /dev/null +++ b/Task/McNuggets-problem/ABC/mcnuggets-problem.abc @@ -0,0 +1,15 @@ +PUT {1..100} IN non.nuggets + +PUT 0 IN a +WHILE a <= 100: + PUT a IN b + WHILE b <= 100: + PUT b IN c + WHILE c <= 100: + IF c in non.nuggets: + REMOVE c FROM non.nuggets + PUT c+20 IN c + PUT b+9 IN b + PUT a+6 IN a + +WRITE "Maximum non-McNuggets number:", max non.nuggets/ diff --git a/Task/Minimum-multiple-of-m-where-digital-sum-equals-m/ABC/minimum-multiple-of-m-where-digital-sum-equals-m.abc b/Task/Minimum-multiple-of-m-where-digital-sum-equals-m/ABC/minimum-multiple-of-m-where-digital-sum-equals-m.abc new file mode 100644 index 0000000000..ab005bff35 --- /dev/null +++ b/Task/Minimum-multiple-of-m-where-digital-sum-equals-m/ABC/minimum-multiple-of-m-where-digital-sum-equals-m.abc @@ -0,0 +1,15 @@ +HOW TO RETURN digit.sum n: + PUT 0 IN sum + WHILE n>0: + PUT sum + (n mod 10) IN sum + PUT floor (n/10) IN n + RETURN sum + +HOW TO RETURN a131382 n: + PUT 1 IN m + WHILE n <> digit.sum (m*n): PUT m+1 IN m + RETURN m + +FOR n IN {1..70}: + WRITE (a131382 n)>>9 + IF n mod 10=0: WRITE / diff --git a/Task/Munchausen-numbers/ABC/munchausen-numbers.abc b/Task/Munchausen-numbers/ABC/munchausen-numbers.abc new file mode 100644 index 0000000000..90e77b6977 --- /dev/null +++ b/Task/Munchausen-numbers/ABC/munchausen-numbers.abc @@ -0,0 +1,11 @@ +HOW TO REPORT munchausen n: + PUT 0 IN sum + PUT n IN m + WHILE m > 0: + PUT m mod 10 IN digit + PUT sum + digit**digit IN sum + PUT floor(m/10) IN m + REPORT sum = n + +FOR n IN {1..5000}: + IF munchausen n: WRITE n/ diff --git a/Task/Mutual-recursion/ABC/mutual-recursion.abc b/Task/Mutual-recursion/ABC/mutual-recursion.abc new file mode 100644 index 0000000000..18d68ee335 --- /dev/null +++ b/Task/Mutual-recursion/ABC/mutual-recursion.abc @@ -0,0 +1,15 @@ +HOW TO RETURN f n: + IF n=0: RETURN 1 + RETURN n - m f (n-1) + +HOW TO RETURN m n: + IF n=0: RETURN 0 + RETURN n - f m (n-1) + +WRITE "F:" +FOR n IN {0..15}: WRITE f n +WRITE / + +WRITE "M:" +FOR n IN {0..15}: WRITE m n +WRITE / diff --git a/Task/Nth/Stringle/nth.stringle b/Task/Nth/Stringle/nth.stringle new file mode 100644 index 0000000000..0de43b4064 --- /dev/null +++ b/Task/Nth/Stringle/nth.stringle @@ -0,0 +1,11 @@ +#i +s "th" +.\#i "1" .:\#i !"1" s "st" +.\#i "2" .:\#i !"1" s "nd" +.\#i "3" .:\#i !"1" s "rd" +$ #i s +i i "." +#i +26 26 +#i #@i 250 +#i +266 266 +#i #@i 1000 +#i +1026 i "" +#i diff --git a/Task/Primality-by-trial-division/ABC/primality-by-trial-division.abc b/Task/Primality-by-trial-division/ABC/primality-by-trial-division.abc new file mode 100644 index 0000000000..e1ad1669f9 --- /dev/null +++ b/Task/Primality-by-trial-division/ABC/primality-by-trial-division.abc @@ -0,0 +1,5 @@ +HOW TO REPORT prime n: + REPORT n>=2 AND NO d IN {2..floor root n} HAS n mod d = 0 + +FOR n IN {1..100}: + IF prime n: WRITE n diff --git a/Task/Rep-string/ABC/rep-string.abc b/Task/Rep-string/ABC/rep-string.abc new file mode 100644 index 0000000000..c5f051bff8 --- /dev/null +++ b/Task/Rep-string/ABC/rep-string.abc @@ -0,0 +1,24 @@ +HOW TO RETURN repstrings str: + PUT {} IN reps + FOR len IN {0..floor(#str/2-1)}: + PUT str|floor(#str/2-len) IN rep + PUT rep IN rpt + WHILE #rpt < #str: PUT rpt^rep IN rpt + IF rpt|#str = str: INSERT rep IN reps + RETURN reps + +PUT {} IN tests +PUT "1001110011" IN tests[1] +PUT "1110111011" IN tests[2] +PUT "0010010010" IN tests[3] +PUT "1010101010" IN tests[4] +PUT "1111111111" IN tests[5] +PUT "0100101101" IN tests[6] +PUT "0100100" IN tests[7] +PUT "101" IN tests[8] +PUT "11" IN tests[9] +PUT "00" IN tests[10] +PUT "1" IN tests[11] + +FOR t IN tests: + WRITE t, repstrings t / diff --git a/Task/Reverse-a-string/Stringle/reverse-a-string.stringle b/Task/Reverse-a-string/Stringle/reverse-a-string.stringle new file mode 100644 index 0000000000..38f00ea0c9 --- /dev/null +++ b/Task/Reverse-a-string/Stringle/reverse-a-string.stringle @@ -0,0 +1 @@ +$ \$ diff --git a/Task/Rot-13/Stringle/rot-13.stringle b/Task/Rot-13/Stringle/rot-13.stringle new file mode 100644 index 0000000000..5111c34fbe --- /dev/null +++ b/Task/Rot-13/Stringle/rot-13.stringle @@ -0,0 +1,15 @@ +a "The quick brown fox jumps over the lazy dog." +b "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz" +c b +#@c 78 +#\c 52 +#a +b %.a d " " b +b %.a #d .a +b %.a e c +b %.a #e #d +b %.a a .\e :a +f f .a +a :a +#a +$ f diff --git a/Task/Sequence-of-non-squares/ABC/sequence-of-non-squares.abc b/Task/Sequence-of-non-squares/ABC/sequence-of-non-squares.abc new file mode 100644 index 0000000000..d22b73a6ed --- /dev/null +++ b/Task/Sequence-of-non-squares/ABC/sequence-of-non-squares.abc @@ -0,0 +1,11 @@ +HOW TO RETURN non.square n: + RETURN n + floor (1/2 + root n) + +HOW TO REPORT square n: + REPORT n = (floor root n)**2 + +FOR n IN {1..22}: WRITE non.square n +WRITE / + +IF NO n IN {1..1000000} HAS square non.square n: + WRITE "No squares occur for n < 1.000.000" diff --git a/Task/Sieve-of-Eratosthenes/ABC/sieve-of-eratosthenes.abc b/Task/Sieve-of-Eratosthenes/ABC/sieve-of-eratosthenes.abc new file mode 100644 index 0000000000..f5dc36980c --- /dev/null +++ b/Task/Sieve-of-Eratosthenes/ABC/sieve-of-eratosthenes.abc @@ -0,0 +1,19 @@ +HOW TO SIEVE UP TO n: + SHARE sieve + PUT {} IN sieve + FOR cand IN {2..n}: PUT 1 IN sieve[cand] + FOR cand IN {2..floor root n}: + IF sieve[cand] = 1: + PUT cand*cand IN comp + WHILE comp <= n: + PUT 0 IN sieve[comp] + PUT comp+cand IN comp + +HOW TO REPORT prime n: + SHARE sieve + IF n<2: FAIL + REPORT sieve[n] = 1 + +SIEVE UP TO 100 +FOR n IN {1..100}: + IF prime n: WRITE n diff --git a/Task/Smith-numbers/ABC/smith-numbers.abc b/Task/Smith-numbers/ABC/smith-numbers.abc new file mode 100644 index 0000000000..c108b1bb10 --- /dev/null +++ b/Task/Smith-numbers/ABC/smith-numbers.abc @@ -0,0 +1,36 @@ +HOW TO RETURN factors n: + PUT {} IN factors + PUT 2 IN factor + WHILE n >= factor: + SELECT: + n mod factor = 0: + INSERT factor IN factors + PUT n/factor IN n + ELSE: + PUT factor+1 IN factor + RETURN factors + +HOW TO RETURN digit.sum n: + PUT 0 IN sum + WHILE n > 0: + PUT sum + (n mod 10) IN sum + PUT floor (n/10) IN n + RETURN sum + +HOW TO REPORT smith.number n: + PUT factors n IN facs + IF #facs = 1: FAIL + PUT 0 IN fac.dsum + FOR fac IN facs: + PUT fac.dsum + digit.sum fac IN fac.dsum + REPORT fac.dsum = digit.sum n + +PUT 0 IN col +FOR i IN {1..9999}: + IF smith.number i: + WRITE (i>>5) + PUT col+1 IN col + IF col=16: + WRITE / + PUT 0 IN col +WRITE / diff --git a/Task/String-length/Stringle/string-length.stringle b/Task/String-length/Stringle/string-length.stringle new file mode 100644 index 0000000000..cffc444026 --- /dev/null +++ b/Task/String-length/Stringle/string-length.stringle @@ -0,0 +1 @@ +$ #$ diff --git a/Task/Strip-a-set-of-characters-from-a-string/ABC/strip-a-set-of-characters-from-a-string.abc b/Task/Strip-a-set-of-characters-from-a-string/ABC/strip-a-set-of-characters-from-a-string.abc new file mode 100644 index 0000000000..70c7150aae --- /dev/null +++ b/Task/Strip-a-set-of-characters-from-a-string/ABC/strip-a-set-of-characters-from-a-string.abc @@ -0,0 +1,7 @@ +HOW TO RETURN s stripchars chs: + PUT "" IN result + FOR c IN s: + IF c not.in chs: PUT result^c IN result + RETURN result + +WRITE "She was a soul stripper. She took my heart!" stripchars "aei"/ diff --git a/Task/Strip-a-set-of-characters-from-a-string/Stringle/strip-a-set-of-characters-from-a-string.stringle b/Task/Strip-a-set-of-characters-from-a-string/Stringle/strip-a-set-of-characters-from-a-string.stringle new file mode 100644 index 0000000000..0385c1457e --- /dev/null +++ b/Task/Strip-a-set-of-characters-from-a-string/Stringle/strip-a-set-of-characters-from-a-string.stringle @@ -0,0 +1,8 @@ +a "She was a soul stripper. She took my heart!" +b "aei" +#a +c c .a +b %.\c #c #:c +a :a +#a +$ c diff --git a/Task/Towers-of-Hanoi/ABC/towers-of-hanoi.abc b/Task/Towers-of-Hanoi/ABC/towers-of-hanoi.abc new file mode 100644 index 0000000000..7e386f588d --- /dev/null +++ b/Task/Towers-of-Hanoi/ABC/towers-of-hanoi.abc @@ -0,0 +1,7 @@ +HOW TO MOVE n DISKS FROM src VIA via TO dest: + IF n>0: + MOVE n-1 DISKS FROM src VIA dest TO via + WRITE "Move disk from pole", src, "to pole", dest/ + MOVE n-1 DISKS FROM via VIA dest TO src + +MOVE 4 DISKS FROM 1 VIA 2 TO 3 diff --git a/Task/Van-Eck-sequence/ABC/van-eck-sequence.abc b/Task/Van-Eck-sequence/ABC/van-eck-sequence.abc new file mode 100644 index 0000000000..e1fa80bae3 --- /dev/null +++ b/Task/Van-Eck-sequence/ABC/van-eck-sequence.abc @@ -0,0 +1,15 @@ +HOW TO RETURN vaneck.sequence length: + PUT {[1]: 0} IN seq + WHILE #seq < length: + PUT #seq-1 IN i + WHILE i>0 AND seq[i]<>seq[#seq]: PUT i-1 IN i + SELECT: + i=0: PUT 0 IN seq[#seq+1] + ELSE: PUT #seq-i IN seq[#seq+1] + RETURN seq + +PUT vaneck.sequence 1000 IN eck +FOR i IN {1..10}: WRITE eck[i]>>4 +WRITE / +FOR i IN {991..1000}: WRITE eck[i]>>4 +WRITE /